├── LICENSE
├── README.md
└── my_example
├── my_ball.sln
└── suspension_ball
├── ImGui
├── font.h
├── imconfig.h
├── imgui.cpp
├── imgui.h
├── imgui_demo.cpp
├── imgui_draw.cpp
├── imgui_impl_glfw.cpp
├── imgui_impl_glfw.h
├── imgui_impl_opengl3.cpp
├── imgui_impl_opengl3.h
├── imgui_impl_opengl3_loader.h
├── imgui_internal.h
├── imgui_tables.cpp
├── imgui_widgets.cpp
├── imstb_rectpack.h
├── imstb_textedit.h
├── imstb_truetype.h
└── stb_image.h
├── draw.h
├── global.h
├── icon.h
├── knobs
├── imgui-knobs.cpp
└── imgui-knobs.h
├── libs
└── glfw
│ ├── COPYING.txt
│ ├── include
│ └── GLFW
│ │ ├── glfw3.h
│ │ └── glfw3native.h
│ └── lib-vc2010-64
│ └── glfw3.lib
├── log
├── log.cpp
├── log.h
└── log_animation.h
├── main.cpp
├── suspension_ball.vcxproj
├── suspension_ball.vcxproj.filters
├── suspension_ball.vcxproj.user
├── theme
├── Gradient.h
└── themes.h
└── widget.h
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ImGui_FloatBall
2 | An example of a floating ball for Android and PC
3 |
4 | # License
5 | [](https://www.gnu.org/licenses/gpl-3.0)
6 |
--------------------------------------------------------------------------------
/my_example/my_ball.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.2.32630.192
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "suspension_ball", "suspension_ball\suspension_ball.vcxproj", "{6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Debug|x64.ActiveCfg = Debug|x64
17 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Debug|x64.Build.0 = Debug|x64
18 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Debug|x86.ActiveCfg = Debug|Win32
19 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Debug|x86.Build.0 = Debug|Win32
20 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Release|x64.ActiveCfg = Release|x64
21 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Release|x64.Build.0 = Release|x64
22 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Release|x86.ActiveCfg = Release|Win32
23 | {6D9EF402-7EF2-44B4-B2EC-E482FE4C7935}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {52F954B1-8032-4485-BBD4-E3B7549CB945}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/my_example/suspension_ball/ImGui/font.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dalvqw/ImGui_FloatBall/e2e7726965dee0d3721743b35bc8fe7d17eaf7b0/my_example/suspension_ball/ImGui/font.h
--------------------------------------------------------------------------------
/my_example/suspension_ball/ImGui/imconfig.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI
3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
5 | //-----------------------------------------------------------------------------
6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
8 | //-----------------------------------------------------------------------------
9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
12 | // 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.
13 | //-----------------------------------------------------------------------------
14 |
15 | #pragma once
16 |
17 | //---- Define assertion handler. Defaults to calling assert().
18 | // 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.
19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
21 |
22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
23 | // 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.
24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
26 | //#define IMGUI_API __declspec( dllexport )
27 | //#define IMGUI_API __declspec( dllimport )
28 |
29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
31 | //#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87: disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This will be folded into IMGUI_DISABLE_OBSOLETE_FUNCTIONS in a few versions.
32 |
33 | //---- Disable all of Dear ImGui or don't implement standard windows/tools.
34 | // It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
35 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
36 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
37 | //#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowStackToolWindow() will be empty (this was called IMGUI_DISABLE_METRICS_WINDOW before 1.88).
38 |
39 | //---- Don't implement some functions to reduce linkage requirements.
40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a)
41 | //#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW)
42 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a)
43 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
44 | //#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).
45 | //#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)
46 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
47 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies)
48 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle 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.
49 | //#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().
50 | //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available
51 |
52 | //---- Include imgui_user.h at the end of imgui.h as a convenience
53 | //#define IMGUI_INCLUDE_IMGUI_USER_H
54 |
55 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
56 | //#define IMGUI_USE_BGRA_PACKED_COLOR
57 |
58 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...)
59 | //#define IMGUI_USE_WCHAR32
60 |
61 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
62 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files.
63 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
64 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
65 | //#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if enabled
66 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
67 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
68 |
69 | //---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined)
70 | // Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h.
71 | //#define IMGUI_USE_STB_SPRINTF
72 |
73 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui)
74 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided).
75 | // On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'.
76 | //#define IMGUI_ENABLE_FREETYPE
77 |
78 | //---- Use stb_truetype to build and rasterize the font atlas (default)
79 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend.
80 | //#define IMGUI_ENABLE_STB_TRUETYPE
81 |
82 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
83 | // This will be inlined as part of ImVec2 and ImVec4 class declarations.
84 | /*
85 | #define IM_VEC2_CLASS_EXTRA \
86 | constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \
87 | operator MyVec2() const { return MyVec2(x,y); }
88 |
89 | #define IM_VEC4_CLASS_EXTRA \
90 | constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \
91 | operator MyVec4() const { return MyVec4(x,y,z,w); }
92 | */
93 |
94 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
95 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
96 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
97 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
98 | //#define ImDrawIdx unsigned int
99 |
100 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
101 | //struct ImDrawList;
102 | //struct ImDrawCmd;
103 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
104 | //#define ImDrawCallback MyImDrawCallback
105 |
106 | //---- Debug Tools: Macro to break in Debugger
107 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
108 | //#define IM_DEBUG_BREAK IM_ASSERT(0)
109 | //#define IM_DEBUG_BREAK __debugbreak()
110 |
111 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
112 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
113 | // This adds a small runtime cost which is why it is not enabled by default.
114 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
115 |
116 | //---- Debug Tools: Enable slower asserts
117 | //#define IMGUI_DEBUG_PARANOID
118 |
119 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
120 | /*
121 | namespace ImGui
122 | {
123 | void MyFunction(const char* name, const MyMatrix44& v);
124 | }
125 | */
126 |
--------------------------------------------------------------------------------
/my_example/suspension_ball/ImGui/imgui_impl_glfw.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Platform Backend for GLFW
2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..)
3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
4 | // (Requires: GLFW 3.1+. Prefer GLFW 3.3+ for full feature support.)
5 |
6 | // Implemented features:
7 | // [X] Platform: Clipboard support.
8 | // [X] Platform: Keyboard support. Since 1.87 we are using the io.AddKeyEvent() function. Pass ImGuiKey values to all key functions e.g. ImGui::IsKeyPressed(ImGuiKey_Space). [Legacy GLFW_KEY_* values will also be supported unless IMGUI_DISABLE_OBSOLETE_KEYIO is set]
9 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
10 | // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
11 | // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
12 |
13 | // Issues:
14 | // [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
15 |
16 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
17 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
18 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
19 | // Read online: https://github.com/ocornut/imgui/tree/master/docs
20 |
21 | #pragma once
22 | #include "imgui.h" // IMGUI_IMPL_API
23 |
24 | struct GLFWwindow;
25 | struct GLFWmonitor;
26 |
27 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
28 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
29 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks);
30 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
31 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
32 |
33 | // GLFW callbacks (installer)
34 | // - When calling Init with 'install_callbacks=true': ImGui_ImplGlfw_InstallCallbacks() is called. GLFW callbacks will be installed for you. They will chain-call user's previously installed callbacks, if any.
35 | // - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call individual function yourself from your own GLFW callbacks.
36 | IMGUI_IMPL_API void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window);
37 | IMGUI_IMPL_API void ImGui_ImplGlfw_RestoreCallbacks(GLFWwindow* window);
38 |
39 | // GLFW callbacks (individual callbacks to call if you didn't install callbacks)
40 | IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); // Since 1.84
41 | IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); // Since 1.84
42 | IMGUI_IMPL_API void ImGui_ImplGlfw_CursorPosCallback(GLFWwindow* window, double x, double y); // Since 1.87
43 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
44 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
45 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
46 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
47 | IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event);
48 |
--------------------------------------------------------------------------------
/my_example/suspension_ball/ImGui/imgui_impl_opengl3.h:
--------------------------------------------------------------------------------
1 | // dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline
2 | // - Desktop GL: 2.x 3.x 4.x
3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
4 | // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
5 |
6 | // Implemented features:
7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
8 | // [X] Renderer: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
9 | // [x] Renderer: Large meshes support (64k+ vertices) with 16-bit indices (Desktop OpenGL only).
10 |
11 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
12 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
13 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
14 | // Read online: https://github.com/ocornut/imgui/tree/master/docs
15 |
16 | // About GLSL version:
17 | // The 'glsl_version' initialization parameter should be nullptr (default) or a "#version XXX" string.
18 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
19 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
20 |
21 | #pragma once
22 | #include "imgui.h" // IMGUI_IMPL_API
23 |
24 | // Backend API
25 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = nullptr);
26 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
27 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
28 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
29 |
30 | // (Optional) Called by Init/NewFrame/Shutdown
31 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
32 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
33 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
34 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
35 |
36 | // Specific OpenGL ES versions
37 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
38 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
39 |
40 | // You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
41 | #if !defined(IMGUI_IMPL_OPENGL_ES2) \
42 | && !defined(IMGUI_IMPL_OPENGL_ES3)
43 |
44 | // Try to detect GLES on matching platforms
45 | #if defined(__APPLE__)
46 | #include
47 | #endif
48 | #if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
49 | #define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
50 | #elif defined(__EMSCRIPTEN__) || defined(__amigaos4__)
51 | #define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
52 | #else
53 | // Otherwise imgui_impl_opengl3_loader.h will be used.
54 | #endif
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/my_example/suspension_ball/ImGui/imgui_impl_opengl3_loader.h:
--------------------------------------------------------------------------------
1 | //-----------------------------------------------------------------------------
2 | // About imgui_impl_opengl3_loader.h:
3 | //
4 | // We embed our own OpenGL loader to not require user to provide their own or to have to use ours,
5 | // which proved to be endless problems for users.
6 | // Our loader is custom-generated, based on gl3w but automatically filtered to only include
7 | // enums/functions that we use in our imgui_impl_opengl3.cpp source file in order to be small.
8 | //
9 | // YOU SHOULD NOT NEED TO INCLUDE/USE THIS DIRECTLY. THIS IS USED BY imgui_impl_opengl3.cpp ONLY.
10 | // THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE.
11 | //
12 | // IF YOU GET BUILD ERRORS IN THIS FILE (commonly macro redefinitions or function redefinitions):
13 | // IT LIKELY MEANS THAT YOU ARE BUILDING 'imgui_impl_opengl3.cpp' OR INCUDING 'imgui_impl_opengl3_loader.h'
14 | // IN THE SAME COMPILATION UNIT AS ONE OF YOUR FILE WHICH IS USING A THIRD-PARTY OPENGL LOADER.
15 | // (e.g. COULD HAPPEN IF YOU ARE DOING A UNITY/JUMBO BUILD, OR INCLUDING .CPP FILES FROM OTHERS)
16 | // YOU SHOULD NOT BUILD BOTH IN THE SAME COMPILATION UNIT.
17 | // BUT IF YOU REALLY WANT TO, you can '#define IMGUI_IMPL_OPENGL_LOADER_CUSTOM' and imgui_impl_opengl3.cpp
18 | // WILL NOT BE USING OUR LOADER, AND INSTEAD EXPECT ANOTHER/YOUR LOADER TO BE AVAILABLE IN THE COMPILATION UNIT.
19 | //
20 | // Regenerate with:
21 | // python gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt
22 | //
23 | // More info:
24 | // https://github.com/dearimgui/gl3w_stripped
25 | // https://github.com/ocornut/imgui/issues/4445
26 | //-----------------------------------------------------------------------------
27 |
28 | /*
29 | * This file was generated with gl3w_gen.py, part of imgl3w
30 | * (hosted at https://github.com/dearimgui/gl3w_stripped)
31 | *
32 | * This is free and unencumbered software released into the public domain.
33 | *
34 | * Anyone is free to copy, modify, publish, use, compile, sell, or
35 | * distribute this software, either in source code form or as a compiled
36 | * binary, for any purpose, commercial or non-commercial, and by any
37 | * means.
38 | *
39 | * In jurisdictions that recognize copyright laws, the author or authors
40 | * of this software dedicate any and all copyright interest in the
41 | * software to the public domain. We make this dedication for the benefit
42 | * of the public at large and to the detriment of our heirs and
43 | * successors. We intend this dedication to be an overt act of
44 | * relinquishment in perpetuity of all present and future rights to this
45 | * software under copyright law.
46 | *
47 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
51 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
52 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
53 | * OTHER DEALINGS IN THE SOFTWARE.
54 | */
55 |
56 | #ifndef __gl3w_h_
57 | #define __gl3w_h_
58 |
59 | // Adapted from KHR/khrplatform.h to avoid including entire file.
60 | #ifndef __khrplatform_h_
61 | typedef float khronos_float_t;
62 | typedef signed char khronos_int8_t;
63 | typedef unsigned char khronos_uint8_t;
64 | typedef signed short int khronos_int16_t;
65 | typedef unsigned short int khronos_uint16_t;
66 | #ifdef _WIN64
67 | typedef signed long long int khronos_intptr_t;
68 | typedef signed long long int khronos_ssize_t;
69 | #else
70 | typedef signed long int khronos_intptr_t;
71 | typedef signed long int khronos_ssize_t;
72 | #endif
73 |
74 | #if defined(_MSC_VER) && !defined(__clang__)
75 | typedef signed __int64 khronos_int64_t;
76 | typedef unsigned __int64 khronos_uint64_t;
77 | #elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100)
78 | #include
79 | typedef int64_t khronos_int64_t;
80 | typedef uint64_t khronos_uint64_t;
81 | #else
82 | typedef signed long long khronos_int64_t;
83 | typedef unsigned long long khronos_uint64_t;
84 | #endif
85 | #endif // __khrplatform_h_
86 |
87 | #ifndef __gl_glcorearb_h_
88 | #define __gl_glcorearb_h_ 1
89 | #ifdef __cplusplus
90 | extern "C" {
91 | #endif
92 | /*
93 | ** Copyright 2013-2020 The Khronos Group Inc.
94 | ** SPDX-License-Identifier: MIT
95 | **
96 | ** This header is generated from the Khronos OpenGL / OpenGL ES XML
97 | ** API Registry. The current version of the Registry, generator scripts
98 | ** used to make the header, and the header can be found at
99 | ** https://github.com/KhronosGroup/OpenGL-Registry
100 | */
101 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
102 | #ifndef WIN32_LEAN_AND_MEAN
103 | #define WIN32_LEAN_AND_MEAN 1
104 | #endif
105 | #include
106 | #endif
107 | #ifndef APIENTRY
108 | #define APIENTRY
109 | #endif
110 | #ifndef APIENTRYP
111 | #define APIENTRYP APIENTRY *
112 | #endif
113 | #ifndef GLAPI
114 | #define GLAPI extern
115 | #endif
116 | /* glcorearb.h is for use with OpenGL core profile implementations.
117 | ** It should should be placed in the same directory as gl.h and
118 | ** included as .
119 | **
120 | ** glcorearb.h includes only APIs in the latest OpenGL core profile
121 | ** implementation together with APIs in newer ARB extensions which
122 | ** can be supported by the core profile. It does not, and never will
123 | ** include functionality removed from the core profile, such as
124 | ** fixed-function vertex and fragment processing.
125 | **
126 | ** Do not #include both and either of or
127 | ** in the same source file.
128 | */
129 | /* Generated C header for:
130 | * API: gl
131 | * Profile: core
132 | * Versions considered: .*
133 | * Versions emitted: .*
134 | * Default extensions included: glcore
135 | * Additional extensions included: _nomatch_^
136 | * Extensions removed: _nomatch_^
137 | */
138 | #ifndef GL_VERSION_1_0
139 | typedef void GLvoid;
140 | typedef unsigned int GLenum;
141 |
142 | typedef khronos_float_t GLfloat;
143 | typedef int GLint;
144 | typedef int GLsizei;
145 | typedef unsigned int GLbitfield;
146 | typedef double GLdouble;
147 | typedef unsigned int GLuint;
148 | typedef unsigned char GLboolean;
149 | typedef khronos_uint8_t GLubyte;
150 | #define GL_COLOR_BUFFER_BIT 0x00004000
151 | #define GL_FALSE 0
152 | #define GL_TRUE 1
153 | #define GL_TRIANGLES 0x0004
154 | #define GL_ONE 1
155 | #define GL_SRC_ALPHA 0x0302
156 | #define GL_ONE_MINUS_SRC_ALPHA 0x0303
157 | #define GL_FRONT_AND_BACK 0x0408
158 | #define GL_POLYGON_MODE 0x0B40
159 | #define GL_CULL_FACE 0x0B44
160 | #define GL_DEPTH_TEST 0x0B71
161 | #define GL_STENCIL_TEST 0x0B90
162 | #define GL_VIEWPORT 0x0BA2
163 | #define GL_BLEND 0x0BE2
164 | #define GL_SCISSOR_BOX 0x0C10
165 | #define GL_SCISSOR_TEST 0x0C11
166 | #define GL_UNPACK_ROW_LENGTH 0x0CF2
167 | #define GL_PACK_ALIGNMENT 0x0D05
168 | #define GL_TEXTURE_2D 0x0DE1
169 | #define GL_UNSIGNED_BYTE 0x1401
170 | #define GL_UNSIGNED_SHORT 0x1403
171 | #define GL_UNSIGNED_INT 0x1405
172 | #define GL_FLOAT 0x1406
173 | #define GL_RGBA 0x1908
174 | #define GL_FILL 0x1B02
175 | #define GL_VENDOR 0x1F00
176 | #define GL_RENDERER 0x1F01
177 | #define GL_VERSION 0x1F02
178 | #define GL_EXTENSIONS 0x1F03
179 | #define GL_LINEAR 0x2601
180 | #define GL_TEXTURE_MAG_FILTER 0x2800
181 | #define GL_TEXTURE_MIN_FILTER 0x2801
182 | typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode);
183 | typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
184 | typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
185 | typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
186 | typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
187 | typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
188 | typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap);
189 | typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap);
190 | typedef void (APIENTRYP PFNGLFLUSHPROC) (void);
191 | typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
192 | typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
193 | typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void);
194 | typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data);
195 | typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
196 | typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap);
197 | typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
198 | #ifdef GL_GLEXT_PROTOTYPES
199 | GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode);
200 | GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
201 | GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
202 | GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
203 | GLAPI void APIENTRY glClear (GLbitfield mask);
204 | GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
205 | GLAPI void APIENTRY glDisable (GLenum cap);
206 | GLAPI void APIENTRY glEnable (GLenum cap);
207 | GLAPI void APIENTRY glFlush (void);
208 | GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param);
209 | GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
210 | GLAPI GLenum APIENTRY glGetError (void);
211 | GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data);
212 | GLAPI const GLubyte *APIENTRY glGetString (GLenum name);
213 | GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap);
214 | GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
215 | #endif
216 | #endif /* GL_VERSION_1_0 */
217 | #ifndef GL_VERSION_1_1
218 | typedef khronos_float_t GLclampf;
219 | typedef double GLclampd;
220 | #define GL_TEXTURE_BINDING_2D 0x8069
221 | typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices);
222 | typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
223 | typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures);
224 | typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
225 | #ifdef GL_GLEXT_PROTOTYPES
226 | GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
227 | GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture);
228 | GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
229 | GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures);
230 | #endif
231 | #endif /* GL_VERSION_1_1 */
232 | #ifndef GL_VERSION_1_3
233 | #define GL_TEXTURE0 0x84C0
234 | #define GL_ACTIVE_TEXTURE 0x84E0
235 | typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
236 | #ifdef GL_GLEXT_PROTOTYPES
237 | GLAPI void APIENTRY glActiveTexture (GLenum texture);
238 | #endif
239 | #endif /* GL_VERSION_1_3 */
240 | #ifndef GL_VERSION_1_4
241 | #define GL_BLEND_DST_RGB 0x80C8
242 | #define GL_BLEND_SRC_RGB 0x80C9
243 | #define GL_BLEND_DST_ALPHA 0x80CA
244 | #define GL_BLEND_SRC_ALPHA 0x80CB
245 | #define GL_FUNC_ADD 0x8006
246 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
247 | typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
248 | #ifdef GL_GLEXT_PROTOTYPES
249 | GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
250 | GLAPI void APIENTRY glBlendEquation (GLenum mode);
251 | #endif
252 | #endif /* GL_VERSION_1_4 */
253 | #ifndef GL_VERSION_1_5
254 | typedef khronos_ssize_t GLsizeiptr;
255 | typedef khronos_intptr_t GLintptr;
256 | #define GL_ARRAY_BUFFER 0x8892
257 | #define GL_ELEMENT_ARRAY_BUFFER 0x8893
258 | #define GL_ARRAY_BUFFER_BINDING 0x8894
259 | #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
260 | #define GL_STREAM_DRAW 0x88E0
261 | typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
262 | typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
263 | typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
264 | typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
265 | typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
266 | #ifdef GL_GLEXT_PROTOTYPES
267 | GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer);
268 | GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
269 | GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
270 | GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
271 | GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
272 | #endif
273 | #endif /* GL_VERSION_1_5 */
274 | #ifndef GL_VERSION_2_0
275 | typedef char GLchar;
276 | typedef khronos_int16_t GLshort;
277 | typedef khronos_int8_t GLbyte;
278 | typedef khronos_uint16_t GLushort;
279 | #define GL_BLEND_EQUATION_RGB 0x8009
280 | #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
281 | #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
282 | #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
283 | #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
284 | #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
285 | #define GL_BLEND_EQUATION_ALPHA 0x883D
286 | #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
287 | #define GL_FRAGMENT_SHADER 0x8B30
288 | #define GL_VERTEX_SHADER 0x8B31
289 | #define GL_COMPILE_STATUS 0x8B81
290 | #define GL_LINK_STATUS 0x8B82
291 | #define GL_INFO_LOG_LENGTH 0x8B84
292 | #define GL_CURRENT_PROGRAM 0x8B8D
293 | #define GL_UPPER_LEFT 0x8CA2
294 | typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
295 | typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
296 | typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
297 | typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
298 | typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
299 | typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
300 | typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
301 | typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
302 | typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
303 | typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
304 | typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
305 | typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
306 | typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
307 | typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
308 | typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
309 | typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
310 | typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
311 | typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer);
312 | typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
313 | typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
314 | typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
315 | typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
316 | typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
317 | typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
318 | #ifdef GL_GLEXT_PROTOTYPES
319 | GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
320 | GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader);
321 | GLAPI void APIENTRY glCompileShader (GLuint shader);
322 | GLAPI GLuint APIENTRY glCreateProgram (void);
323 | GLAPI GLuint APIENTRY glCreateShader (GLenum type);
324 | GLAPI void APIENTRY glDeleteProgram (GLuint program);
325 | GLAPI void APIENTRY glDeleteShader (GLuint shader);
326 | GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader);
327 | GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index);
328 | GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index);
329 | GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
330 | GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
331 | GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
332 | GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
333 | GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
334 | GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
335 | GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
336 | GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
337 | GLAPI void APIENTRY glLinkProgram (GLuint program);
338 | GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
339 | GLAPI void APIENTRY glUseProgram (GLuint program);
340 | GLAPI void APIENTRY glUniform1i (GLint location, GLint v0);
341 | GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
342 | GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
343 | #endif
344 | #endif /* GL_VERSION_2_0 */
345 | #ifndef GL_VERSION_3_0
346 | typedef khronos_uint16_t GLhalf;
347 | #define GL_MAJOR_VERSION 0x821B
348 | #define GL_MINOR_VERSION 0x821C
349 | #define GL_NUM_EXTENSIONS 0x821D
350 | #define GL_FRAMEBUFFER_SRGB 0x8DB9
351 | #define GL_VERTEX_ARRAY_BINDING 0x85B5
352 | typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
353 | typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
354 | typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
355 | typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
356 | typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
357 | typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
358 | #ifdef GL_GLEXT_PROTOTYPES
359 | GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index);
360 | GLAPI void APIENTRY glBindVertexArray (GLuint array);
361 | GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
362 | GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
363 | #endif
364 | #endif /* GL_VERSION_3_0 */
365 | #ifndef GL_VERSION_3_1
366 | #define GL_VERSION_3_1 1
367 | #define GL_PRIMITIVE_RESTART 0x8F9D
368 | #endif /* GL_VERSION_3_1 */
369 | #ifndef GL_VERSION_3_2
370 | #define GL_VERSION_3_2 1
371 | typedef struct __GLsync *GLsync;
372 | typedef khronos_uint64_t GLuint64;
373 | typedef khronos_int64_t GLint64;
374 | typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
375 | typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
376 | #ifdef GL_GLEXT_PROTOTYPES
377 | GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
378 | #endif
379 | #endif /* GL_VERSION_3_2 */
380 | #ifndef GL_VERSION_3_3
381 | #define GL_VERSION_3_3 1
382 | #define GL_SAMPLER_BINDING 0x8919
383 | typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
384 | #ifdef GL_GLEXT_PROTOTYPES
385 | GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler);
386 | #endif
387 | #endif /* GL_VERSION_3_3 */
388 | #ifndef GL_VERSION_4_1
389 | typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data);
390 | typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data);
391 | #endif /* GL_VERSION_4_1 */
392 | #ifndef GL_VERSION_4_3
393 | typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
394 | #endif /* GL_VERSION_4_3 */
395 | #ifndef GL_VERSION_4_5
396 | #define GL_CLIP_ORIGIN 0x935C
397 | typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param);
398 | typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param);
399 | #endif /* GL_VERSION_4_5 */
400 | #ifndef GL_ARB_bindless_texture
401 | typedef khronos_uint64_t GLuint64EXT;
402 | #endif /* GL_ARB_bindless_texture */
403 | #ifndef GL_ARB_cl_event
404 | struct _cl_context;
405 | struct _cl_event;
406 | #endif /* GL_ARB_cl_event */
407 | #ifndef GL_ARB_clip_control
408 | #define GL_ARB_clip_control 1
409 | #endif /* GL_ARB_clip_control */
410 | #ifndef GL_ARB_debug_output
411 | typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
412 | #endif /* GL_ARB_debug_output */
413 | #ifndef GL_EXT_EGL_image_storage
414 | typedef void *GLeglImageOES;
415 | #endif /* GL_EXT_EGL_image_storage */
416 | #ifndef GL_EXT_direct_state_access
417 | typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params);
418 | typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params);
419 | typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params);
420 | typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param);
421 | typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param);
422 | #endif /* GL_EXT_direct_state_access */
423 | #ifndef GL_NV_draw_vulkan_image
424 | typedef void (APIENTRY *GLVULKANPROCNV)(void);
425 | #endif /* GL_NV_draw_vulkan_image */
426 | #ifndef GL_NV_gpu_shader5
427 | typedef khronos_int64_t GLint64EXT;
428 | #endif /* GL_NV_gpu_shader5 */
429 | #ifndef GL_NV_vertex_buffer_unified_memory
430 | typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
431 | #endif /* GL_NV_vertex_buffer_unified_memory */
432 | #ifdef __cplusplus
433 | }
434 | #endif
435 | #endif
436 |
437 | #ifndef GL3W_API
438 | #define GL3W_API
439 | #endif
440 |
441 | #ifndef __gl_h_
442 | #define __gl_h_
443 | #endif
444 |
445 | #ifdef __cplusplus
446 | extern "C" {
447 | #endif
448 |
449 | #define GL3W_OK 0
450 | #define GL3W_ERROR_INIT -1
451 | #define GL3W_ERROR_LIBRARY_OPEN -2
452 | #define GL3W_ERROR_OPENGL_VERSION -3
453 |
454 | typedef void (*GL3WglProc)(void);
455 | typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc);
456 |
457 | /* gl3w api */
458 | GL3W_API int imgl3wInit(void);
459 | GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc);
460 | GL3W_API int imgl3wIsSupported(int major, int minor);
461 | GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc);
462 |
463 | /* gl3w internal state */
464 | union GL3WProcs {
465 | GL3WglProc ptr[58];
466 | struct {
467 | PFNGLACTIVETEXTUREPROC ActiveTexture;
468 | PFNGLATTACHSHADERPROC AttachShader;
469 | PFNGLBINDBUFFERPROC BindBuffer;
470 | PFNGLBINDSAMPLERPROC BindSampler;
471 | PFNGLBINDTEXTUREPROC BindTexture;
472 | PFNGLBINDVERTEXARRAYPROC BindVertexArray;
473 | PFNGLBLENDEQUATIONPROC BlendEquation;
474 | PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate;
475 | PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate;
476 | PFNGLBUFFERDATAPROC BufferData;
477 | PFNGLBUFFERSUBDATAPROC BufferSubData;
478 | PFNGLCLEARPROC Clear;
479 | PFNGLCLEARCOLORPROC ClearColor;
480 | PFNGLCOMPILESHADERPROC CompileShader;
481 | PFNGLCREATEPROGRAMPROC CreateProgram;
482 | PFNGLCREATESHADERPROC CreateShader;
483 | PFNGLDELETEBUFFERSPROC DeleteBuffers;
484 | PFNGLDELETEPROGRAMPROC DeleteProgram;
485 | PFNGLDELETESHADERPROC DeleteShader;
486 | PFNGLDELETETEXTURESPROC DeleteTextures;
487 | PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays;
488 | PFNGLDETACHSHADERPROC DetachShader;
489 | PFNGLDISABLEPROC Disable;
490 | PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray;
491 | PFNGLDRAWELEMENTSPROC DrawElements;
492 | PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex;
493 | PFNGLENABLEPROC Enable;
494 | PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray;
495 | PFNGLFLUSHPROC Flush;
496 | PFNGLGENBUFFERSPROC GenBuffers;
497 | PFNGLGENTEXTURESPROC GenTextures;
498 | PFNGLGENVERTEXARRAYSPROC GenVertexArrays;
499 | PFNGLGETATTRIBLOCATIONPROC GetAttribLocation;
500 | PFNGLGETERRORPROC GetError;
501 | PFNGLGETINTEGERVPROC GetIntegerv;
502 | PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog;
503 | PFNGLGETPROGRAMIVPROC GetProgramiv;
504 | PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog;
505 | PFNGLGETSHADERIVPROC GetShaderiv;
506 | PFNGLGETSTRINGPROC GetString;
507 | PFNGLGETSTRINGIPROC GetStringi;
508 | PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation;
509 | PFNGLGETVERTEXATTRIBPOINTERVPROC GetVertexAttribPointerv;
510 | PFNGLGETVERTEXATTRIBIVPROC GetVertexAttribiv;
511 | PFNGLISENABLEDPROC IsEnabled;
512 | PFNGLLINKPROGRAMPROC LinkProgram;
513 | PFNGLPIXELSTOREIPROC PixelStorei;
514 | PFNGLPOLYGONMODEPROC PolygonMode;
515 | PFNGLREADPIXELSPROC ReadPixels;
516 | PFNGLSCISSORPROC Scissor;
517 | PFNGLSHADERSOURCEPROC ShaderSource;
518 | PFNGLTEXIMAGE2DPROC TexImage2D;
519 | PFNGLTEXPARAMETERIPROC TexParameteri;
520 | PFNGLUNIFORM1IPROC Uniform1i;
521 | PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv;
522 | PFNGLUSEPROGRAMPROC UseProgram;
523 | PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer;
524 | PFNGLVIEWPORTPROC Viewport;
525 | } gl;
526 | };
527 |
528 | GL3W_API extern union GL3WProcs imgl3wProcs;
529 |
530 | /* OpenGL functions */
531 | #define glActiveTexture imgl3wProcs.gl.ActiveTexture
532 | #define glAttachShader imgl3wProcs.gl.AttachShader
533 | #define glBindBuffer imgl3wProcs.gl.BindBuffer
534 | #define glBindSampler imgl3wProcs.gl.BindSampler
535 | #define glBindTexture imgl3wProcs.gl.BindTexture
536 | #define glBindVertexArray imgl3wProcs.gl.BindVertexArray
537 | #define glBlendEquation imgl3wProcs.gl.BlendEquation
538 | #define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate
539 | #define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate
540 | #define glBufferData imgl3wProcs.gl.BufferData
541 | #define glBufferSubData imgl3wProcs.gl.BufferSubData
542 | #define glClear imgl3wProcs.gl.Clear
543 | #define glClearColor imgl3wProcs.gl.ClearColor
544 | #define glCompileShader imgl3wProcs.gl.CompileShader
545 | #define glCreateProgram imgl3wProcs.gl.CreateProgram
546 | #define glCreateShader imgl3wProcs.gl.CreateShader
547 | #define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers
548 | #define glDeleteProgram imgl3wProcs.gl.DeleteProgram
549 | #define glDeleteShader imgl3wProcs.gl.DeleteShader
550 | #define glDeleteTextures imgl3wProcs.gl.DeleteTextures
551 | #define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays
552 | #define glDetachShader imgl3wProcs.gl.DetachShader
553 | #define glDisable imgl3wProcs.gl.Disable
554 | #define glDisableVertexAttribArray imgl3wProcs.gl.DisableVertexAttribArray
555 | #define glDrawElements imgl3wProcs.gl.DrawElements
556 | #define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex
557 | #define glEnable imgl3wProcs.gl.Enable
558 | #define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray
559 | #define glFlush imgl3wProcs.gl.Flush
560 | #define glGenBuffers imgl3wProcs.gl.GenBuffers
561 | #define glGenTextures imgl3wProcs.gl.GenTextures
562 | #define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays
563 | #define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation
564 | #define glGetError imgl3wProcs.gl.GetError
565 | #define glGetIntegerv imgl3wProcs.gl.GetIntegerv
566 | #define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog
567 | #define glGetProgramiv imgl3wProcs.gl.GetProgramiv
568 | #define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog
569 | #define glGetShaderiv imgl3wProcs.gl.GetShaderiv
570 | #define glGetString imgl3wProcs.gl.GetString
571 | #define glGetStringi imgl3wProcs.gl.GetStringi
572 | #define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation
573 | #define glGetVertexAttribPointerv imgl3wProcs.gl.GetVertexAttribPointerv
574 | #define glGetVertexAttribiv imgl3wProcs.gl.GetVertexAttribiv
575 | #define glIsEnabled imgl3wProcs.gl.IsEnabled
576 | #define glLinkProgram imgl3wProcs.gl.LinkProgram
577 | #define glPixelStorei imgl3wProcs.gl.PixelStorei
578 | #define glPolygonMode imgl3wProcs.gl.PolygonMode
579 | #define glReadPixels imgl3wProcs.gl.ReadPixels
580 | #define glScissor imgl3wProcs.gl.Scissor
581 | #define glShaderSource imgl3wProcs.gl.ShaderSource
582 | #define glTexImage2D imgl3wProcs.gl.TexImage2D
583 | #define glTexParameteri imgl3wProcs.gl.TexParameteri
584 | #define glUniform1i imgl3wProcs.gl.Uniform1i
585 | #define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv
586 | #define glUseProgram imgl3wProcs.gl.UseProgram
587 | #define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer
588 | #define glViewport imgl3wProcs.gl.Viewport
589 |
590 | #ifdef __cplusplus
591 | }
592 | #endif
593 |
594 | #endif
595 |
596 | #ifdef IMGL3W_IMPL
597 | #ifdef __cplusplus
598 | extern "C" {
599 | #endif
600 |
601 | #include
602 |
603 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
604 |
605 | #if defined(_WIN32)
606 | #ifndef WIN32_LEAN_AND_MEAN
607 | #define WIN32_LEAN_AND_MEAN 1
608 | #endif
609 | #include
610 |
611 | static HMODULE libgl;
612 | typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR);
613 | static GL3WglGetProcAddr wgl_get_proc_address;
614 |
615 | static int open_libgl(void)
616 | {
617 | libgl = LoadLibraryA("opengl32.dll");
618 | if (!libgl)
619 | return GL3W_ERROR_LIBRARY_OPEN;
620 | wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress");
621 | return GL3W_OK;
622 | }
623 |
624 | static void close_libgl(void) { FreeLibrary(libgl); }
625 | static GL3WglProc get_proc(const char *proc)
626 | {
627 | GL3WglProc res;
628 | res = (GL3WglProc)wgl_get_proc_address(proc);
629 | if (!res)
630 | res = (GL3WglProc)GetProcAddress(libgl, proc);
631 | return res;
632 | }
633 | #elif defined(__APPLE__)
634 | #include
635 |
636 | static void *libgl;
637 | static int open_libgl(void)
638 | {
639 | libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
640 | if (!libgl)
641 | return GL3W_ERROR_LIBRARY_OPEN;
642 | return GL3W_OK;
643 | }
644 |
645 | static void close_libgl(void) { dlclose(libgl); }
646 |
647 | static GL3WglProc get_proc(const char *proc)
648 | {
649 | GL3WglProc res;
650 | *(void **)(&res) = dlsym(libgl, proc);
651 | return res;
652 | }
653 | #else
654 | #include
655 |
656 | static void *libgl;
657 | static GL3WglProc (*glx_get_proc_address)(const GLubyte *);
658 |
659 | static int open_libgl(void)
660 | {
661 | libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL);
662 | if (!libgl)
663 | return GL3W_ERROR_LIBRARY_OPEN;
664 | *(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB");
665 | return GL3W_OK;
666 | }
667 |
668 | static void close_libgl(void) { dlclose(libgl); }
669 |
670 | static GL3WglProc get_proc(const char *proc)
671 | {
672 | GL3WglProc res;
673 | res = glx_get_proc_address((const GLubyte *)proc);
674 | if (!res)
675 | *(void **)(&res) = dlsym(libgl, proc);
676 | return res;
677 | }
678 | #endif
679 |
680 | static struct { int major, minor; } version;
681 |
682 | static int parse_version(void)
683 | {
684 | if (!glGetIntegerv)
685 | return GL3W_ERROR_INIT;
686 | glGetIntegerv(GL_MAJOR_VERSION, &version.major);
687 | glGetIntegerv(GL_MINOR_VERSION, &version.minor);
688 | if (version.major < 3)
689 | return GL3W_ERROR_OPENGL_VERSION;
690 | return GL3W_OK;
691 | }
692 |
693 | static void load_procs(GL3WGetProcAddressProc proc);
694 |
695 | int imgl3wInit(void)
696 | {
697 | int res = open_libgl();
698 | if (res)
699 | return res;
700 | atexit(close_libgl);
701 | return imgl3wInit2(get_proc);
702 | }
703 |
704 | int imgl3wInit2(GL3WGetProcAddressProc proc)
705 | {
706 | load_procs(proc);
707 | return parse_version();
708 | }
709 |
710 | int imgl3wIsSupported(int major, int minor)
711 | {
712 | if (major < 3)
713 | return 0;
714 | if (version.major == major)
715 | return version.minor >= minor;
716 | return version.major >= major;
717 | }
718 |
719 | GL3WglProc imgl3wGetProcAddress(const char *proc) { return get_proc(proc); }
720 |
721 | static const char *proc_names[] = {
722 | "glActiveTexture",
723 | "glAttachShader",
724 | "glBindBuffer",
725 | "glBindSampler",
726 | "glBindTexture",
727 | "glBindVertexArray",
728 | "glBlendEquation",
729 | "glBlendEquationSeparate",
730 | "glBlendFuncSeparate",
731 | "glBufferData",
732 | "glBufferSubData",
733 | "glClear",
734 | "glClearColor",
735 | "glCompileShader",
736 | "glCreateProgram",
737 | "glCreateShader",
738 | "glDeleteBuffers",
739 | "glDeleteProgram",
740 | "glDeleteShader",
741 | "glDeleteTextures",
742 | "glDeleteVertexArrays",
743 | "glDetachShader",
744 | "glDisable",
745 | "glDisableVertexAttribArray",
746 | "glDrawElements",
747 | "glDrawElementsBaseVertex",
748 | "glEnable",
749 | "glEnableVertexAttribArray",
750 | "glFlush",
751 | "glGenBuffers",
752 | "glGenTextures",
753 | "glGenVertexArrays",
754 | "glGetAttribLocation",
755 | "glGetError",
756 | "glGetIntegerv",
757 | "glGetProgramInfoLog",
758 | "glGetProgramiv",
759 | "glGetShaderInfoLog",
760 | "glGetShaderiv",
761 | "glGetString",
762 | "glGetStringi",
763 | "glGetUniformLocation",
764 | "glGetVertexAttribPointerv",
765 | "glGetVertexAttribiv",
766 | "glIsEnabled",
767 | "glLinkProgram",
768 | "glPixelStorei",
769 | "glPolygonMode",
770 | "glReadPixels",
771 | "glScissor",
772 | "glShaderSource",
773 | "glTexImage2D",
774 | "glTexParameteri",
775 | "glUniform1i",
776 | "glUniformMatrix4fv",
777 | "glUseProgram",
778 | "glVertexAttribPointer",
779 | "glViewport",
780 | };
781 |
782 | GL3W_API union GL3WProcs imgl3wProcs;
783 |
784 | static void load_procs(GL3WGetProcAddressProc proc)
785 | {
786 | size_t i;
787 | for (i = 0; i < ARRAY_SIZE(proc_names); i++)
788 | imgl3wProcs.ptr[i] = proc(proc_names[i]);
789 | }
790 |
791 | #ifdef __cplusplus
792 | }
793 | #endif
794 | #endif
795 |
--------------------------------------------------------------------------------
/my_example/suspension_ball/ImGui/imstb_rectpack.h:
--------------------------------------------------------------------------------
1 | // [DEAR IMGUI]
2 | // This is a slightly modified version of stb_rect_pack.h 1.01.
3 | // Grep for [DEAR IMGUI] to find the changes.
4 | //
5 | // stb_rect_pack.h - v1.01 - public domain - rectangle packing
6 | // Sean Barrett 2014
7 | //
8 | // Useful for e.g. packing rectangular textures into an atlas.
9 | // Does not do rotation.
10 | //
11 | // Before #including,
12 | //
13 | // #define STB_RECT_PACK_IMPLEMENTATION
14 | //
15 | // in the file that you want to have the implementation.
16 | //
17 | // Not necessarily the awesomest packing method, but better than
18 | // the totally naive one in stb_truetype (which is primarily what
19 | // this is meant to replace).
20 | //
21 | // Has only had a few tests run, may have issues.
22 | //
23 | // More docs to come.
24 | //
25 | // No memory allocations; uses qsort() and assert() from stdlib.
26 | // Can override those by defining STBRP_SORT and STBRP_ASSERT.
27 | //
28 | // This library currently uses the Skyline Bottom-Left algorithm.
29 | //
30 | // Please note: better rectangle packers are welcome! Please
31 | // implement them to the same API, but with a different init
32 | // function.
33 | //
34 | // Credits
35 | //
36 | // Library
37 | // Sean Barrett
38 | // Minor features
39 | // Martins Mozeiko
40 | // github:IntellectualKitty
41 | //
42 | // Bugfixes / warning fixes
43 | // Jeremy Jaussaud
44 | // Fabian Giesen
45 | //
46 | // Version history:
47 | //
48 | // 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section
49 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
50 | // 0.99 (2019-02-07) warning fixes
51 | // 0.11 (2017-03-03) return packing success/fail result
52 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings
53 | // 0.09 (2016-08-27) fix compiler warnings
54 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
55 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
56 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
57 | // 0.05: added STBRP_ASSERT to allow replacing assert
58 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support
59 | // 0.01: initial release
60 | //
61 | // LICENSE
62 | //
63 | // See end of file for license information.
64 |
65 | //////////////////////////////////////////////////////////////////////////////
66 | //
67 | // INCLUDE SECTION
68 | //
69 |
70 | #ifndef STB_INCLUDE_STB_RECT_PACK_H
71 | #define STB_INCLUDE_STB_RECT_PACK_H
72 |
73 | #define STB_RECT_PACK_VERSION 1
74 |
75 | #ifdef STBRP_STATIC
76 | #define STBRP_DEF static
77 | #else
78 | #define STBRP_DEF extern
79 | #endif
80 |
81 | #ifdef __cplusplus
82 | extern "C" {
83 | #endif
84 |
85 | typedef struct stbrp_context stbrp_context;
86 | typedef struct stbrp_node stbrp_node;
87 | typedef struct stbrp_rect stbrp_rect;
88 |
89 | typedef int stbrp_coord;
90 |
91 | #define STBRP__MAXVAL 0x7fffffff
92 | // Mostly for internal use, but this is the maximum supported coordinate value.
93 |
94 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
95 | // Assign packed locations to rectangles. The rectangles are of type
96 | // 'stbrp_rect' defined below, stored in the array 'rects', and there
97 | // are 'num_rects' many of them.
98 | //
99 | // Rectangles which are successfully packed have the 'was_packed' flag
100 | // set to a non-zero value and 'x' and 'y' store the minimum location
101 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left
102 | // if you imagine y increasing downwards). Rectangles which do not fit
103 | // have the 'was_packed' flag set to 0.
104 | //
105 | // You should not try to access the 'rects' array from another thread
106 | // while this function is running, as the function temporarily reorders
107 | // the array while it executes.
108 | //
109 | // To pack into another rectangle, you need to call stbrp_init_target
110 | // again. To continue packing into the same rectangle, you can call
111 | // this function again. Calling this multiple times with multiple rect
112 | // arrays will probably produce worse packing results than calling it
113 | // a single time with the full rectangle array, but the option is
114 | // available.
115 | //
116 | // The function returns 1 if all of the rectangles were successfully
117 | // packed and 0 otherwise.
118 |
119 | struct stbrp_rect
120 | {
121 | // reserved for your use:
122 | int id;
123 |
124 | // input:
125 | stbrp_coord w, h;
126 |
127 | // output:
128 | stbrp_coord x, y;
129 | int was_packed; // non-zero if valid packing
130 |
131 | }; // 16 bytes, nominally
132 |
133 |
134 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
135 | // Initialize a rectangle packer to:
136 | // pack a rectangle that is 'width' by 'height' in dimensions
137 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long
138 | //
139 | // You must call this function every time you start packing into a new target.
140 | //
141 | // There is no "shutdown" function. The 'nodes' memory must stay valid for
142 | // the following stbrp_pack_rects() call (or calls), but can be freed after
143 | // the call (or calls) finish.
144 | //
145 | // Note: to guarantee best results, either:
146 | // 1. make sure 'num_nodes' >= 'width'
147 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
148 | //
149 | // If you don't do either of the above things, widths will be quantized to multiples
150 | // of small integers to guarantee the algorithm doesn't run out of temporary storage.
151 | //
152 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm
153 | // may run out of temporary storage and be unable to pack some rectangles.
154 |
155 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
156 | // Optionally call this function after init but before doing any packing to
157 | // change the handling of the out-of-temp-memory scenario, described above.
158 | // If you call init again, this will be reset to the default (false).
159 |
160 |
161 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
162 | // Optionally select which packing heuristic the library should use. Different
163 | // heuristics will produce better/worse results for different data sets.
164 | // If you call init again, this will be reset to the default.
165 |
166 | enum
167 | {
168 | STBRP_HEURISTIC_Skyline_default=0,
169 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
170 | STBRP_HEURISTIC_Skyline_BF_sortHeight
171 | };
172 |
173 |
174 | //////////////////////////////////////////////////////////////////////////////
175 | //
176 | // the details of the following structures don't matter to you, but they must
177 | // be visible so you can handle the memory allocations for them
178 |
179 | struct stbrp_node
180 | {
181 | stbrp_coord x,y;
182 | stbrp_node *next;
183 | };
184 |
185 | struct stbrp_context
186 | {
187 | int width;
188 | int height;
189 | int align;
190 | int init_mode;
191 | int heuristic;
192 | int num_nodes;
193 | stbrp_node *active_head;
194 | stbrp_node *free_head;
195 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
196 | };
197 |
198 | #ifdef __cplusplus
199 | }
200 | #endif
201 |
202 | #endif
203 |
204 | //////////////////////////////////////////////////////////////////////////////
205 | //
206 | // IMPLEMENTATION SECTION
207 | //
208 |
209 | #ifdef STB_RECT_PACK_IMPLEMENTATION
210 | #ifndef STBRP_SORT
211 | #include
212 | #define STBRP_SORT qsort
213 | #endif
214 |
215 | #ifndef STBRP_ASSERT
216 | #include
217 | #define STBRP_ASSERT assert
218 | #endif
219 |
220 | #ifdef _MSC_VER
221 | #define STBRP__NOTUSED(v) (void)(v)
222 | #define STBRP__CDECL __cdecl
223 | #else
224 | #define STBRP__NOTUSED(v) (void)sizeof(v)
225 | #define STBRP__CDECL
226 | #endif
227 |
228 | enum
229 | {
230 | STBRP__INIT_skyline = 1
231 | };
232 |
233 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
234 | {
235 | switch (context->init_mode) {
236 | case STBRP__INIT_skyline:
237 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
238 | context->heuristic = heuristic;
239 | break;
240 | default:
241 | STBRP_ASSERT(0);
242 | }
243 | }
244 |
245 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
246 | {
247 | if (allow_out_of_mem)
248 | // if it's ok to run out of memory, then don't bother aligning them;
249 | // this gives better packing, but may fail due to OOM (even though
250 | // the rectangles easily fit). @TODO a smarter approach would be to only
251 | // quantize once we've hit OOM, then we could get rid of this parameter.
252 | context->align = 1;
253 | else {
254 | // if it's not ok to run out of memory, then quantize the widths
255 | // so that num_nodes is always enough nodes.
256 | //
257 | // I.e. num_nodes * align >= width
258 | // align >= width / num_nodes
259 | // align = ceil(width/num_nodes)
260 |
261 | context->align = (context->width + context->num_nodes-1) / context->num_nodes;
262 | }
263 | }
264 |
265 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
266 | {
267 | int i;
268 |
269 | for (i=0; i < num_nodes-1; ++i)
270 | nodes[i].next = &nodes[i+1];
271 | nodes[i].next = NULL;
272 | context->init_mode = STBRP__INIT_skyline;
273 | context->heuristic = STBRP_HEURISTIC_Skyline_default;
274 | context->free_head = &nodes[0];
275 | context->active_head = &context->extra[0];
276 | context->width = width;
277 | context->height = height;
278 | context->num_nodes = num_nodes;
279 | stbrp_setup_allow_out_of_mem(context, 0);
280 |
281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
282 | context->extra[0].x = 0;
283 | context->extra[0].y = 0;
284 | context->extra[0].next = &context->extra[1];
285 | context->extra[1].x = (stbrp_coord) width;
286 | context->extra[1].y = (1<<30);
287 | context->extra[1].next = NULL;
288 | }
289 |
290 | // find minimum y position if it starts at x1
291 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
292 | {
293 | stbrp_node *node = first;
294 | int x1 = x0 + width;
295 | int min_y, visited_width, waste_area;
296 |
297 | STBRP__NOTUSED(c);
298 |
299 | STBRP_ASSERT(first->x <= x0);
300 |
301 | #if 0
302 | // skip in case we're past the node
303 | while (node->next->x <= x0)
304 | ++node;
305 | #else
306 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
307 | #endif
308 |
309 | STBRP_ASSERT(node->x <= x0);
310 |
311 | min_y = 0;
312 | waste_area = 0;
313 | visited_width = 0;
314 | while (node->x < x1) {
315 | if (node->y > min_y) {
316 | // raise min_y higher.
317 | // we've accounted for all waste up to min_y,
318 | // but we'll now add more waste for everything we've visted
319 | waste_area += visited_width * (node->y - min_y);
320 | min_y = node->y;
321 | // the first time through, visited_width might be reduced
322 | if (node->x < x0)
323 | visited_width += node->next->x - x0;
324 | else
325 | visited_width += node->next->x - node->x;
326 | } else {
327 | // add waste area
328 | int under_width = node->next->x - node->x;
329 | if (under_width + visited_width > width)
330 | under_width = width - visited_width;
331 | waste_area += under_width * (min_y - node->y);
332 | visited_width += under_width;
333 | }
334 | node = node->next;
335 | }
336 |
337 | *pwaste = waste_area;
338 | return min_y;
339 | }
340 |
341 | typedef struct
342 | {
343 | int x,y;
344 | stbrp_node **prev_link;
345 | } stbrp__findresult;
346 |
347 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
348 | {
349 | int best_waste = (1<<30), best_x, best_y = (1 << 30);
350 | stbrp__findresult fr;
351 | stbrp_node **prev, *node, *tail, **best = NULL;
352 |
353 | // align to multiple of c->align
354 | width = (width + c->align - 1);
355 | width -= width % c->align;
356 | STBRP_ASSERT(width % c->align == 0);
357 |
358 | // if it can't possibly fit, bail immediately
359 | if (width > c->width || height > c->height) {
360 | fr.prev_link = NULL;
361 | fr.x = fr.y = 0;
362 | return fr;
363 | }
364 |
365 | node = c->active_head;
366 | prev = &c->active_head;
367 | while (node->x + width <= c->width) {
368 | int y,waste;
369 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
370 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
371 | // bottom left
372 | if (y < best_y) {
373 | best_y = y;
374 | best = prev;
375 | }
376 | } else {
377 | // best-fit
378 | if (y + height <= c->height) {
379 | // can only use it if it first vertically
380 | if (y < best_y || (y == best_y && waste < best_waste)) {
381 | best_y = y;
382 | best_waste = waste;
383 | best = prev;
384 | }
385 | }
386 | }
387 | prev = &node->next;
388 | node = node->next;
389 | }
390 |
391 | best_x = (best == NULL) ? 0 : (*best)->x;
392 |
393 | // if doing best-fit (BF), we also have to try aligning right edge to each node position
394 | //
395 | // e.g, if fitting
396 | //
397 | // ____________________
398 | // |____________________|
399 | //
400 | // into
401 | //
402 | // | |
403 | // | ____________|
404 | // |____________|
405 | //
406 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
407 | //
408 | // This makes BF take about 2x the time
409 |
410 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
411 | tail = c->active_head;
412 | node = c->active_head;
413 | prev = &c->active_head;
414 | // find first node that's admissible
415 | while (tail->x < width)
416 | tail = tail->next;
417 | while (tail) {
418 | int xpos = tail->x - width;
419 | int y,waste;
420 | STBRP_ASSERT(xpos >= 0);
421 | // find the left position that matches this
422 | while (node->next->x <= xpos) {
423 | prev = &node->next;
424 | node = node->next;
425 | }
426 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
427 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
428 | if (y + height <= c->height) {
429 | if (y <= best_y) {
430 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
431 | best_x = xpos;
432 | //STBRP_ASSERT(y <= best_y); [DEAR IMGUI]
433 | best_y = y;
434 | best_waste = waste;
435 | best = prev;
436 | }
437 | }
438 | }
439 | tail = tail->next;
440 | }
441 | }
442 |
443 | fr.prev_link = best;
444 | fr.x = best_x;
445 | fr.y = best_y;
446 | return fr;
447 | }
448 |
449 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
450 | {
451 | // find best position according to heuristic
452 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
453 | stbrp_node *node, *cur;
454 |
455 | // bail if:
456 | // 1. it failed
457 | // 2. the best node doesn't fit (we don't always check this)
458 | // 3. we're out of memory
459 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
460 | res.prev_link = NULL;
461 | return res;
462 | }
463 |
464 | // on success, create new node
465 | node = context->free_head;
466 | node->x = (stbrp_coord) res.x;
467 | node->y = (stbrp_coord) (res.y + height);
468 |
469 | context->free_head = node->next;
470 |
471 | // insert the new node into the right starting point, and
472 | // let 'cur' point to the remaining nodes needing to be
473 | // stiched back in
474 |
475 | cur = *res.prev_link;
476 | if (cur->x < res.x) {
477 | // preserve the existing one, so start testing with the next one
478 | stbrp_node *next = cur->next;
479 | cur->next = node;
480 | cur = next;
481 | } else {
482 | *res.prev_link = node;
483 | }
484 |
485 | // from here, traverse cur and free the nodes, until we get to one
486 | // that shouldn't be freed
487 | while (cur->next && cur->next->x <= res.x + width) {
488 | stbrp_node *next = cur->next;
489 | // move the current node to the free list
490 | cur->next = context->free_head;
491 | context->free_head = cur;
492 | cur = next;
493 | }
494 |
495 | // stitch the list back in
496 | node->next = cur;
497 |
498 | if (cur->x < res.x + width)
499 | cur->x = (stbrp_coord) (res.x + width);
500 |
501 | #ifdef _DEBUG
502 | cur = context->active_head;
503 | while (cur->x < context->width) {
504 | STBRP_ASSERT(cur->x < cur->next->x);
505 | cur = cur->next;
506 | }
507 | STBRP_ASSERT(cur->next == NULL);
508 |
509 | {
510 | int count=0;
511 | cur = context->active_head;
512 | while (cur) {
513 | cur = cur->next;
514 | ++count;
515 | }
516 | cur = context->free_head;
517 | while (cur) {
518 | cur = cur->next;
519 | ++count;
520 | }
521 | STBRP_ASSERT(count == context->num_nodes+2);
522 | }
523 | #endif
524 |
525 | return res;
526 | }
527 |
528 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
529 | {
530 | const stbrp_rect *p = (const stbrp_rect *) a;
531 | const stbrp_rect *q = (const stbrp_rect *) b;
532 | if (p->h > q->h)
533 | return -1;
534 | if (p->h < q->h)
535 | return 1;
536 | return (p->w > q->w) ? -1 : (p->w < q->w);
537 | }
538 |
539 | static int STBRP__CDECL rect_original_order(const void *a, const void *b)
540 | {
541 | const stbrp_rect *p = (const stbrp_rect *) a;
542 | const stbrp_rect *q = (const stbrp_rect *) b;
543 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
544 | }
545 |
546 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
547 | {
548 | int i, all_rects_packed = 1;
549 |
550 | // we use the 'was_packed' field internally to allow sorting/unsorting
551 | for (i=0; i < num_rects; ++i) {
552 | rects[i].was_packed = i;
553 | }
554 |
555 | // sort according to heuristic
556 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
557 |
558 | for (i=0; i < num_rects; ++i) {
559 | if (rects[i].w == 0 || rects[i].h == 0) {
560 | rects[i].x = rects[i].y = 0; // empty rect needs no space
561 | } else {
562 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
563 | if (fr.prev_link) {
564 | rects[i].x = (stbrp_coord) fr.x;
565 | rects[i].y = (stbrp_coord) fr.y;
566 | } else {
567 | rects[i].x = rects[i].y = STBRP__MAXVAL;
568 | }
569 | }
570 | }
571 |
572 | // unsort
573 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
574 |
575 | // set was_packed flags and all_rects_packed status
576 | for (i=0; i < num_rects; ++i) {
577 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
578 | if (!rects[i].was_packed)
579 | all_rects_packed = 0;
580 | }
581 |
582 | // return the all_rects_packed status
583 | return all_rects_packed;
584 | }
585 | #endif
586 |
587 | /*
588 | ------------------------------------------------------------------------------
589 | This software is available under 2 licenses -- choose whichever you prefer.
590 | ------------------------------------------------------------------------------
591 | ALTERNATIVE A - MIT License
592 | Copyright (c) 2017 Sean Barrett
593 | Permission is hereby granted, free of charge, to any person obtaining a copy of
594 | this software and associated documentation files (the "Software"), to deal in
595 | the Software without restriction, including without limitation the rights to
596 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
597 | of the Software, and to permit persons to whom the Software is furnished to do
598 | so, subject to the following conditions:
599 | The above copyright notice and this permission notice shall be included in all
600 | copies or substantial portions of the Software.
601 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
602 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
603 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
604 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
605 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
606 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
607 | SOFTWARE.
608 | ------------------------------------------------------------------------------
609 | ALTERNATIVE B - Public Domain (www.unlicense.org)
610 | This is free and unencumbered software released into the public domain.
611 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
612 | software, either in source code form or as a compiled binary, for any purpose,
613 | commercial or non-commercial, and by any means.
614 | In jurisdictions that recognize copyright laws, the author or authors of this
615 | software dedicate any and all copyright interest in the software to the public
616 | domain. We make this dedication for the benefit of the public at large and to
617 | the detriment of our heirs and successors. We intend this dedication to be an
618 | overt act of relinquishment in perpetuity of all present and future rights to
619 | this software under copyright law.
620 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
621 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
622 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
623 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
624 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
625 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
626 | ------------------------------------------------------------------------------
627 | */
628 |
--------------------------------------------------------------------------------
/my_example/suspension_ball/draw.h:
--------------------------------------------------------------------------------
1 | #ifndef DRAW_H
2 | #define DRAW_H
3 |
4 | #define STB_IMAGE_IMPLEMENTATION
5 | #include "ImGui/stb_image.h"
6 | #include "ImGui/imgui.h"
7 | #include