├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── doc └── intro.md ├── examples └── examples │ ├── basic.clj │ ├── camera2d.clj │ ├── input_mouse.clj │ └── mouse_wheel.clj ├── java └── raylib │ └── jna │ ├── AudioStream.java │ ├── BoneInfo.java │ ├── BoundingBox.java │ ├── Camera2D.java │ ├── Camera3D.java │ ├── CharInfo.java │ ├── Color.java │ ├── Font.java │ ├── Image.java │ ├── Material.java │ ├── MaterialMap.java │ ├── Matrix.java │ ├── Mesh.java │ ├── Model.java │ ├── ModelAnimation.java │ ├── Music.java │ ├── NPatchInfo.java │ ├── RAudioBuffer.java │ ├── Ray.java │ ├── RayHitInfo.java │ ├── Raylib.java │ ├── Rectangle.java │ ├── RenderTexture2D.java │ ├── Shader.java │ ├── Sound.java │ ├── Texture2D.java │ ├── Transform.java │ ├── Vector2.java │ ├── Vector3.java │ ├── Vector4.java │ ├── VrDeviceInfo.java │ └── Wave.java ├── project.clj ├── src ├── clj_raylib │ └── core.clj ├── darwin │ └── libraylib.3.0.0.dylib ├── linux-x86-64 │ └── libraylib.so.3.0.0 ├── linux-x86 │ └── libraylib.so.3.0.0 ├── win32-x86-64 │ └── libraylib.dll └── win32-x86 │ └── libraylib.dll └── test └── clj_raylib └── core_test.clj /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | profiles.clj 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2020-05-02 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2020-05-02 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/clj-raylib/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/clj-raylib/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 2.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE 4 | PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION 5 | OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial content 12 | Distributed under this Agreement, and 13 | 14 | b) in the case of each subsequent Contributor: 15 | i) changes to the Program, and 16 | ii) additions to the Program; 17 | where such changes and/or additions to the Program originate from 18 | and are Distributed by that particular Contributor. A Contribution 19 | "originates" from a Contributor if it was added to the Program by 20 | such Contributor itself or anyone acting on such Contributor's behalf. 21 | Contributions do not include changes or additions to the Program that 22 | are not Modified Works. 23 | 24 | "Contributor" means any person or entity that Distributes the Program. 25 | 26 | "Licensed Patents" mean patent claims licensable by a Contributor which 27 | are necessarily infringed by the use or sale of its Contribution alone 28 | or when combined with the Program. 29 | 30 | "Program" means the Contributions Distributed in accordance with this 31 | Agreement. 32 | 33 | "Recipient" means anyone who receives the Program under this Agreement 34 | or any Secondary License (as applicable), including Contributors. 35 | 36 | "Derivative Works" shall mean any work, whether in Source Code or other 37 | form, that is based on (or derived from) the Program and for which the 38 | editorial revisions, annotations, elaborations, or other modifications 39 | represent, as a whole, an original work of authorship. 40 | 41 | "Modified Works" shall mean any work in Source Code or other form that 42 | results from an addition to, deletion from, or modification of the 43 | contents of the Program, including, for purposes of clarity any new file 44 | in Source Code form that contains any contents of the Program. Modified 45 | Works shall not include works that contain only declarations, 46 | interfaces, types, classes, structures, or files of the Program solely 47 | in each case in order to link to, bind by name, or subclass the Program 48 | or Modified Works thereof. 49 | 50 | "Distribute" means the acts of a) distributing or b) making available 51 | in any manner that enables the transfer of a copy. 52 | 53 | "Source Code" means the form of a Program preferred for making 54 | modifications, including but not limited to software source code, 55 | documentation source, and configuration files. 56 | 57 | "Secondary License" means either the GNU General Public License, 58 | Version 2.0, or any later versions of that license, including any 59 | exceptions or additional permissions as identified by the initial 60 | Contributor. 61 | 62 | 2. GRANT OF RIGHTS 63 | 64 | a) Subject to the terms of this Agreement, each Contributor hereby 65 | grants Recipient a non-exclusive, worldwide, royalty-free copyright 66 | license to reproduce, prepare Derivative Works of, publicly display, 67 | publicly perform, Distribute and sublicense the Contribution of such 68 | Contributor, if any, and such Derivative Works. 69 | 70 | b) Subject to the terms of this Agreement, each Contributor hereby 71 | grants Recipient a non-exclusive, worldwide, royalty-free patent 72 | license under Licensed Patents to make, use, sell, offer to sell, 73 | import and otherwise transfer the Contribution of such Contributor, 74 | if any, in Source Code or other form. This patent license shall 75 | apply to the combination of the Contribution and the Program if, at 76 | the time the Contribution is added by the Contributor, such addition 77 | of the Contribution causes such combination to be covered by the 78 | Licensed Patents. The patent license shall not apply to any other 79 | combinations which include the Contribution. No hardware per se is 80 | licensed hereunder. 81 | 82 | c) Recipient understands that although each Contributor grants the 83 | licenses to its Contributions set forth herein, no assurances are 84 | provided by any Contributor that the Program does not infringe the 85 | patent or other intellectual property rights of any other entity. 86 | Each Contributor disclaims any liability to Recipient for claims 87 | brought by any other entity based on infringement of intellectual 88 | property rights or otherwise. As a condition to exercising the 89 | rights and licenses granted hereunder, each Recipient hereby 90 | assumes sole responsibility to secure any other intellectual 91 | property rights needed, if any. For example, if a third party 92 | patent license is required to allow Recipient to Distribute the 93 | Program, it is Recipient's responsibility to acquire that license 94 | before distributing the Program. 95 | 96 | d) Each Contributor represents that to its knowledge it has 97 | sufficient copyright rights in its Contribution, if any, to grant 98 | the copyright license set forth in this Agreement. 99 | 100 | e) Notwithstanding the terms of any Secondary License, no 101 | Contributor makes additional grants to any Recipient (other than 102 | those set forth in this Agreement) as a result of such Recipient's 103 | receipt of the Program under the terms of a Secondary License 104 | (if permitted under the terms of Section 3). 105 | 106 | 3. REQUIREMENTS 107 | 108 | 3.1 If a Contributor Distributes the Program in any form, then: 109 | 110 | a) the Program must also be made available as Source Code, in 111 | accordance with section 3.2, and the Contributor must accompany 112 | the Program with a statement that the Source Code for the Program 113 | is available under this Agreement, and informs Recipients how to 114 | obtain it in a reasonable manner on or through a medium customarily 115 | used for software exchange; and 116 | 117 | b) the Contributor may Distribute the Program under a license 118 | different than this Agreement, provided that such license: 119 | i) effectively disclaims on behalf of all other Contributors all 120 | warranties and conditions, express and implied, including 121 | warranties or conditions of title and non-infringement, and 122 | implied warranties or conditions of merchantability and fitness 123 | for a particular purpose; 124 | 125 | ii) effectively excludes on behalf of all other Contributors all 126 | liability for damages, including direct, indirect, special, 127 | incidental and consequential damages, such as lost profits; 128 | 129 | iii) does not attempt to limit or alter the recipients' rights 130 | in the Source Code under section 3.2; and 131 | 132 | iv) requires any subsequent distribution of the Program by any 133 | party to be under a license that satisfies the requirements 134 | of this section 3. 135 | 136 | 3.2 When the Program is Distributed as Source Code: 137 | 138 | a) it must be made available under this Agreement, or if the 139 | Program (i) is combined with other material in a separate file or 140 | files made available under a Secondary License, and (ii) the initial 141 | Contributor attached to the Source Code the notice described in 142 | Exhibit A of this Agreement, then the Program may be made available 143 | under the terms of such Secondary Licenses, and 144 | 145 | b) a copy of this Agreement must be included with each copy of 146 | the Program. 147 | 148 | 3.3 Contributors may not remove or alter any copyright, patent, 149 | trademark, attribution notices, disclaimers of warranty, or limitations 150 | of liability ("notices") contained within the Program from any copy of 151 | the Program which they Distribute, provided that Contributors may add 152 | their own appropriate notices. 153 | 154 | 4. COMMERCIAL DISTRIBUTION 155 | 156 | Commercial distributors of software may accept certain responsibilities 157 | with respect to end users, business partners and the like. While this 158 | license is intended to facilitate the commercial use of the Program, 159 | the Contributor who includes the Program in a commercial product 160 | offering should do so in a manner which does not create potential 161 | liability for other Contributors. Therefore, if a Contributor includes 162 | the Program in a commercial product offering, such Contributor 163 | ("Commercial Contributor") hereby agrees to defend and indemnify every 164 | other Contributor ("Indemnified Contributor") against any losses, 165 | damages and costs (collectively "Losses") arising from claims, lawsuits 166 | and other legal actions brought by a third party against the Indemnified 167 | Contributor to the extent caused by the acts or omissions of such 168 | Commercial Contributor in connection with its distribution of the Program 169 | in a commercial product offering. The obligations in this section do not 170 | apply to any claims or Losses relating to any actual or alleged 171 | intellectual property infringement. In order to qualify, an Indemnified 172 | Contributor must: a) promptly notify the Commercial Contributor in 173 | writing of such claim, and b) allow the Commercial Contributor to control, 174 | and cooperate with the Commercial Contributor in, the defense and any 175 | related settlement negotiations. The Indemnified Contributor may 176 | participate in any such claim at its own expense. 177 | 178 | For example, a Contributor might include the Program in a commercial 179 | product offering, Product X. That Contributor is then a Commercial 180 | Contributor. If that Commercial Contributor then makes performance 181 | claims, or offers warranties related to Product X, those performance 182 | claims and warranties are such Commercial Contributor's responsibility 183 | alone. Under this section, the Commercial Contributor would have to 184 | defend claims against the other Contributors related to those performance 185 | claims and warranties, and if a court requires any other Contributor to 186 | pay any damages as a result, the Commercial Contributor must pay 187 | those damages. 188 | 189 | 5. NO WARRANTY 190 | 191 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT 192 | PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" 193 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 194 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF 195 | TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 196 | PURPOSE. Each Recipient is solely responsible for determining the 197 | appropriateness of using and distributing the Program and assumes all 198 | risks associated with its exercise of rights under this Agreement, 199 | including but not limited to the risks and costs of program errors, 200 | compliance with applicable laws, damage to or loss of data, programs 201 | or equipment, and unavailability or interruption of operations. 202 | 203 | 6. DISCLAIMER OF LIABILITY 204 | 205 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT 206 | PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS 207 | SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 208 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST 209 | PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 210 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 211 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 212 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE 213 | POSSIBILITY OF SUCH DAMAGES. 214 | 215 | 7. GENERAL 216 | 217 | If any provision of this Agreement is invalid or unenforceable under 218 | applicable law, it shall not affect the validity or enforceability of 219 | the remainder of the terms of this Agreement, and without further 220 | action by the parties hereto, such provision shall be reformed to the 221 | minimum extent necessary to make such provision valid and enforceable. 222 | 223 | If Recipient institutes patent litigation against any entity 224 | (including a cross-claim or counterclaim in a lawsuit) alleging that the 225 | Program itself (excluding combinations of the Program with other software 226 | or hardware) infringes such Recipient's patent(s), then such Recipient's 227 | rights granted under Section 2(b) shall terminate as of the date such 228 | litigation is filed. 229 | 230 | All Recipient's rights under this Agreement shall terminate if it 231 | fails to comply with any of the material terms or conditions of this 232 | Agreement and does not cure such failure in a reasonable period of 233 | time after becoming aware of such noncompliance. If all Recipient's 234 | rights under this Agreement terminate, Recipient agrees to cease use 235 | and distribution of the Program as soon as reasonably practicable. 236 | However, Recipient's obligations under this Agreement and any licenses 237 | granted by Recipient relating to the Program shall continue and survive. 238 | 239 | Everyone is permitted to copy and distribute copies of this Agreement, 240 | but in order to avoid inconsistency the Agreement is copyrighted and 241 | may only be modified in the following manner. The Agreement Steward 242 | reserves the right to publish new versions (including revisions) of 243 | this Agreement from time to time. No one other than the Agreement 244 | Steward has the right to modify this Agreement. The Eclipse Foundation 245 | is the initial Agreement Steward. The Eclipse Foundation may assign the 246 | responsibility to serve as the Agreement Steward to a suitable separate 247 | entity. Each new version of the Agreement will be given a distinguishing 248 | version number. The Program (including Contributions) may always be 249 | Distributed subject to the version of the Agreement under which it was 250 | received. In addition, after a new version of the Agreement is published, 251 | Contributor may elect to Distribute the Program (including its 252 | Contributions) under the new version. 253 | 254 | Except as expressly stated in Sections 2(a) and 2(b) above, Recipient 255 | receives no rights or licenses to the intellectual property of any 256 | Contributor under this Agreement, whether expressly, by implication, 257 | estoppel or otherwise. All rights in the Program not expressly granted 258 | under this Agreement are reserved. Nothing in this Agreement is intended 259 | to be enforceable by any entity that is not a Contributor or Recipient. 260 | No third-party beneficiary rights are created under this Agreement. 261 | 262 | Exhibit A - Form of Secondary Licenses Notice 263 | 264 | "This Source Code may also be made available under the following 265 | Secondary Licenses when the conditions for such availability set forth 266 | in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public 267 | License as published by the Free Software Foundation, either version 2 268 | of the License, or (at your option) any later version, with the GNU 269 | Classpath Exception which is available at 270 | https://www.gnu.org/software/classpath/license.html." 271 | 272 | Simply including a copy of this Agreement, including this Exhibit A 273 | is not sufficient to license the Source Code under Secondary Licenses. 274 | 275 | If it is not possible or desirable to put the notice in a particular 276 | file, then You may include the notice in a location (such as a LICENSE 277 | file in a relevant directory) where a recipient would be likely to 278 | look for such a notice. 279 | 280 | You may add additional accurate notices of copyright ownership. 281 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # clj-raylib 2 | 3 | Clojure bidings to the awesome [raylib](https://www.raylib.com/) library 4 | 5 | ## Usage 6 | 7 | ```clojure 8 | (ns basic 9 | (:require [clj-raylib.core :refer :all]) 10 | (:gen-class)) 11 | 12 | (defn -main 13 | [& _] 14 | (let [width 800 15 | height 450] 16 | (init-window! width height "input keys") 17 | (set-target-fps! 60) 18 | (loop [state {:ball [(/ width 2) (/ height 2)]}] 19 | (when-not (window-should-close?) 20 | (with-drawing 21 | (clear-background! RAYWHITE) 22 | (draw-text! "move the ball with arrow keys" 10 10 20 DARKGRAY) 23 | (draw-circle! (:ball state) 50 MAROON)) 24 | (recur (-> state 25 | (#(if (is-key-down? KEY-RIGHT) (update-in % [:ball 0] inc) %)) 26 | (#(if (is-key-down? KEY-LEFT) (update-in % [:ball 0] dec) %)) 27 | (#(if (is-key-down? KEY-UP) (update-in % [:ball 1] dec) %)) 28 | (#(if (is-key-down? KEY-DOWN) (update-in % [:ball 1] inc) %)))))))) 29 | ``` 30 | 31 | To run the examples, clone this folder and run with: 32 | ```bash 33 | lein run -m input-mouse/-main 34 | ``` 35 | And change the namespace to the accoding example you want. 36 | 37 | ## License 38 | 39 | Copyright © 2020 FIXME 40 | 41 | This program and the accompanying materials are made available under the 42 | terms of the Eclipse Public License 2.0 which is available at 43 | http://www.eclipse.org/legal/epl-2.0. 44 | 45 | This Source Code may also be made available under the following Secondary 46 | Licenses when the conditions for such availability set forth in the Eclipse 47 | Public License, v. 2.0 are satisfied: GNU General Public License as published by 48 | the Free Software Foundation, either version 2 of the License, or (at your 49 | option) any later version, with the GNU Classpath Exception which is available 50 | at https://www.gnu.org/software/classpath/license.html. 51 | -------------------------------------------------------------------------------- /doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to clj-raylib 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /examples/examples/basic.clj: -------------------------------------------------------------------------------- 1 | (ns examples.basic 2 | (:require [clj-raylib.core :refer :all]) 3 | (:gen-class)) 4 | 5 | (defn -main 6 | [& _] 7 | (let [width 800 8 | height 450] 9 | (init-window! width height "input keys") 10 | (set-target-fps! 60) 11 | (loop [state {:ball [(/ width 2) (/ height 2)]}] 12 | (when-not (window-should-close?) 13 | (with-drawing 14 | (clear-background! RAYWHITE) 15 | (draw-text! "move the ball with arrow keys" 10 10 20 DARKGRAY) 16 | (draw-circle! (:ball state) 50 MAROON)) 17 | (recur (-> state 18 | (#(if (is-key-down? KEY-RIGHT) (update-in % [:ball 0] inc) %)) 19 | (#(if (is-key-down? KEY-LEFT) (update-in % [:ball 0] dec) %)) 20 | (#(if (is-key-down? KEY-UP) (update-in % [:ball 1] dec) %)) 21 | (#(if (is-key-down? KEY-DOWN) (update-in % [:ball 1] inc) %)))))))) 22 | -------------------------------------------------------------------------------- /examples/examples/camera2d.clj: -------------------------------------------------------------------------------- 1 | (ns examples.camera2d 2 | (:require [clj-raylib.core :refer :all]) 3 | (:gen-class)) 4 | 5 | (defn -main 6 | [& _] 7 | (let [screen-width 800 8 | screen-height 450 9 | max-buildings 100 10 | building-width 100 11 | player-size 40 12 | buildings (->> (range max-buildings) 13 | (map (partial * building-width)) 14 | (map #(let [building-height (get-random-value 100 800)] 15 | {:width building-width 16 | :height building-height 17 | :y (- screen-height 130 building-height) 18 | :x (- 6000 (* 1 %))}))) 19 | building-colors (repeatedly max-buildings #(do {:r (get-random-value 200 240) 20 | :g (get-random-value 200 240) 21 | :b (get-random-value 200 250) 22 | :a 255}))] 23 | (init-window! screen-width screen-height "raylib [core] example - 2d camera") 24 | (set-target-fps! 60) 25 | (loop [state {:player {:x 400 26 | :y 280 27 | :width player-size 28 | :height player-size} 29 | :camera {:target [(+ player-size 20) (+ player-size 20)] 30 | :offset [(/ screen-width 2) (/ screen-height 2)] 31 | :rotation 0.0 32 | :zoom 1.0}}] 33 | (when-not (window-should-close?) 34 | (with-drawing 35 | (clear-background! RAYWHITE) 36 | (with-mode-2d (:camera state) 37 | (draw-rectangle! -6000 320 13000 8000 DARKGRAY) 38 | (mapv #(draw-rectangle! %1 %2) buildings building-colors) 39 | (draw-rectangle! (:player state) RED) 40 | (draw-line! (get-in state [:camera :target 0]) 41 | (* 10 (- screen-height)) 42 | (get-in state [:camera :target 0]) 43 | (* screen-height 10) 44 | GREEN) 45 | (draw-line! (* (- screen-width) 10) 46 | (get-in state [:camera :target 1]) 47 | (* screen-width 10) 48 | (get-in state [:camera :target 1]) 49 | GREEN)) 50 | (draw-text! "SCREEN AREA" 640 10 20 RED) 51 | (draw-rectangle! 0 0 screen-width 5 RED) 52 | (draw-rectangle! 0 5 5 (- screen-height 10) RED) 53 | (draw-rectangle! (- screen-width 5) 5 5 (- screen-height 10) RED) 54 | (draw-rectangle! 0 (- screen-height 5) screen-width 5 RED) 55 | (draw-rectangle! 10 10 250 113 (fade SKYBLUE 0.5)) 56 | (draw-rectangle-lines! 10 10 250 113 BLUE) 57 | (draw-text! "Free 2d camera controls:" 20 20 10 BLACK) 58 | (draw-text! "- Right/Left to move Offset" 40 40 10 DARKGRAY) 59 | (draw-text! "- Mouse Wheel to Zoom in-out" 40 60 10 DARKGRAY) 60 | (draw-text! "- A / S to Rotate" 40 80 10 DARKGRAY) 61 | (draw-text! "- R to reset Zoom and Rotation", 40, 100, 10, DARKGRAY)) 62 | (recur (-> state 63 | (#(if (is-key-down? KEY-RIGHT) (update-in % [:player :x] + 2) %)) 64 | (#(if (is-key-down? KEY-LEFT) (update-in % [:player :x] - 2) %)) 65 | (#(if (is-key-down? KEY-A) (update-in % [:camera :rotation] dec) %)) 66 | (#(if (is-key-down? KEY-S) (update-in % [:camera :rotation] inc) %)) 67 | (#(if (> (get-in % [:camera :rotation]) 40.0) 68 | (assoc-in % [:camera :rotation] 40.0) 69 | %)) 70 | (#(if (< (get-in % [:camera :rotation]) -40.0) 71 | (assoc-in % [:camera :rotation] -40.0) 72 | %)) 73 | (update-in [:camera :zoom] + (* (get-mouse-wheel-move) 0.05)) 74 | (#(assoc-in % [:camera :target] [(+ (get-in % [:player :x]) 20) (+ (get-in % [:player :y]) 20)])) 75 | (#(if (> (get-in % [:camera :zoom]) 3.0) 76 | (assoc-in % [:camera :zoom] 3.0) 77 | %)) 78 | (#(if (< (get-in % [:camera :zoom]) 0.1) 79 | (assoc-in % [:camera :zoom] 0.1) 80 | %)) 81 | (#(if (is-key-pressed? KEY-R) 82 | (-> % 83 | (assoc-in [:camera :zoom] 1.0) 84 | (assoc-in [:camera :rotation] 0.0)) 85 | %)))))) 86 | (close-window!))) 87 | 88 | -------------------------------------------------------------------------------- /examples/examples/input_mouse.clj: -------------------------------------------------------------------------------- 1 | (ns examples.input-mouse 2 | (:require [clj-raylib.core :refer :all]) 3 | (:gen-class)) 4 | 5 | (defn -main 6 | [& _] 7 | (let [width 800 8 | height 450] 9 | (init-window! width height "input mouse") 10 | (set-target-fps! 60) 11 | (loop [state {:ball-color DARKBLUE}] 12 | (when-not (window-should-close?) 13 | (with-drawing 14 | (clear-background! RAYWHITE) 15 | (draw-text! "move the ball with mouse and click mouse button to change color" 10 10 20 DARKGRAY) 16 | (draw-circle! (get-mouse-position) 50 (:ball-color state))) 17 | (recur (assoc state :ball-color (cond 18 | (is-mouse-button-down? MOUSE-LEFT-BUTTON) VIOLET 19 | (is-mouse-button-down? MOUSE-MIDDLE-BUTTON) LIME 20 | (is-mouse-button-down? MOUSE-RIGHT-BUTTON) RED 21 | :else DARKBLUE))))))) 22 | -------------------------------------------------------------------------------- /examples/examples/mouse_wheel.clj: -------------------------------------------------------------------------------- 1 | (ns examples.mouse-wheel 2 | (:require [clj-raylib.core :refer :all]) 3 | (:gen-class)) 4 | 5 | (defn -main 6 | [& _] 7 | (let [width 800 8 | height 450 9 | scroll-speed 4] 10 | (init-window! width height "input mouse wheel") 11 | (set-target-fps! 60) 12 | (loop [state {:box {:x (- (/ width 2) 40) :y (- (/ height 2) 40)}}] 13 | (when-not (window-should-close?) 14 | (with-drawing 15 | (clear-background! RAYWHITE) 16 | (draw-text! "Use mouse wheel to move the cube up and down!" 10 10 20 DARKGRAY) 17 | (draw-text! (format "Box position Y: %03d" (-> state :box :y)) 10 40 20 DARKGRAY) 18 | (draw-rectangle! (:box state) [50 50] RED)) 19 | (recur (update-in state [:box :y] #(- % (* (get-mouse-wheel-move) scroll-speed)))))))) 20 | -------------------------------------------------------------------------------- /java/raylib/jna/AudioStream.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.RAudioBuffer; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"sampleRate","sampleSize","channels","buffer"}) 10 | public class AudioStream extends Structure{ 11 | public static class ByValue extends AudioStream implements Structure.ByValue{ 12 | public ByValue(){ 13 | super(); 14 | } 15 | 16 | public ByValue(int sampleRate, int sampleSize, int channels, RAudioBuffer.ByReference buffer){ 17 | super(); 18 | this.sampleRate = sampleRate; 19 | this.sampleSize = sampleSize; 20 | this.channels = channels; 21 | this.buffer = buffer; 22 | } 23 | 24 | 25 | public ByValue(APersistentMap map){ 26 | super(map); 27 | } 28 | 29 | public ByValue(ByValue br){ 30 | super((AudioStream)br); 31 | } 32 | 33 | public ByValue(Object obj){ 34 | super(obj); 35 | } 36 | } 37 | 38 | public int sampleRate; 39 | public int sampleSize; 40 | public int channels; 41 | public RAudioBuffer.ByReference buffer; 42 | 43 | public AudioStream(int sampleRate, int sampleSize, int channels, RAudioBuffer.ByReference buffer){ 44 | super(); 45 | this.sampleRate = sampleRate; 46 | this.sampleSize = sampleSize; 47 | this.channels = channels; 48 | this.buffer = buffer; 49 | } 50 | 51 | public AudioStream(AudioStream as){ 52 | super(); 53 | this.sampleRate = as.sampleRate; 54 | this.sampleSize = as.sampleSize; 55 | this.channels = as.channels; 56 | this.buffer = as.buffer; 57 | } 58 | 59 | public AudioStream(APersistentMap map) throws IllegalArgumentException{ 60 | super(); 61 | Number sampleRate = (Number)map.get(Keyword.intern("sampleRate")); 62 | if(sampleRate == null) 63 | throw new IllegalArgumentException("Map needs key :sampleRate"); 64 | this.sampleRate = sampleRate.intValue(); 65 | Number sampleSize = (Number)map.get(Keyword.intern("sampleSize")); 66 | if(sampleSize == null) 67 | throw new IllegalArgumentException("Map needs key :sampleSize"); 68 | this.sampleSize = sampleSize.intValue(); 69 | Number channels = (Number)map.get(Keyword.intern("channels")); 70 | if(channels == null) 71 | throw new IllegalArgumentException("Map needs key :channels"); 72 | this.channels = channels.intValue(); 73 | Object buffer = map.get(Keyword.intern("buffer")); 74 | if(buffer == null) 75 | throw new IllegalArgumentException("Map needs key :buffer"); 76 | this.buffer = (RAudioBuffer.ByReference)buffer; 77 | } 78 | 79 | public AudioStream(Object obj){ 80 | super(); 81 | if(obj instanceof AudioStream){ 82 | AudioStream as = (AudioStream)obj; 83 | this.sampleRate = as.sampleRate; 84 | this.sampleSize = as.sampleSize; 85 | this.channels = as.channels; 86 | this.buffer = as.buffer; 87 | }else if(obj instanceof APersistentMap){ 88 | APersistentMap map = (APersistentMap)obj; 89 | 90 | Number sampleRate = (Number)map.get(Keyword.intern("sampleRate")); 91 | if(sampleRate == null) 92 | throw new IllegalArgumentException("Map needs key :sampleRate"); 93 | this.sampleRate = sampleRate.intValue(); 94 | Number sampleSize = (Number)map.get(Keyword.intern("sampleSize")); 95 | if(sampleSize == null) 96 | throw new IllegalArgumentException("Map needs key :sampleSize"); 97 | this.sampleSize = sampleSize.intValue(); 98 | Number channels = (Number)map.get(Keyword.intern("channels")); 99 | if(channels == null) 100 | throw new IllegalArgumentException("Map needs key :channels"); 101 | this.channels = channels.intValue(); 102 | Object buffer = map.get(Keyword.intern("buffer")); 103 | if(buffer == null) 104 | throw new IllegalArgumentException("Map needs key :buffer"); 105 | this.buffer = (RAudioBuffer.ByReference)buffer; 106 | }else{ 107 | throw new IllegalArgumentException("obj of unsupported type "+obj); 108 | } 109 | } 110 | 111 | 112 | public AudioStream(){ 113 | super(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /java/raylib/jna/BoneInfo.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentMap; 6 | import clojure.lang.Keyword; 7 | 8 | @FieldOrder({"name","parent"}) 9 | public class BoneInfo extends Structure{ 10 | public static class ByReference extends BoneInfo implements Structure.ByReference{ 11 | public ByReference(byte[] name, int parent){ 12 | super(name, parent); 13 | } 14 | 15 | public ByReference(){ 16 | super(); 17 | } 18 | 19 | public ByReference(APersistentMap map){ 20 | super(map); 21 | } 22 | 23 | public ByReference(ByValue boneinfo){ 24 | super(boneinfo); 25 | } 26 | public ByReference(ByReference boneinfo){ 27 | super(boneinfo); 28 | } 29 | public ByReference(Object obj){ 30 | super(obj); 31 | } 32 | } 33 | public static class ByValue extends BoneInfo implements Structure.ByValue{ 34 | public ByValue(byte[] name, int parent){ 35 | super(name, parent); 36 | } 37 | 38 | public ByValue(){ 39 | super(); 40 | } 41 | 42 | public ByValue(APersistentMap map){ 43 | super(map); 44 | } 45 | 46 | public ByValue(ByReference boneinfo){ 47 | super(boneinfo); 48 | } 49 | public ByValue(Object obj){ 50 | super(obj); 51 | } 52 | } 53 | 54 | public byte[] name = new byte[32]; 55 | public int parent; 56 | 57 | public BoneInfo(byte[] name, int parent){ 58 | super(); 59 | this.name = name; 60 | this.parent = parent; 61 | } 62 | 63 | public BoneInfo(BoneInfo boneinfo){ 64 | super(); 65 | System.arraycopy(boneinfo.name, 0, this.name, 0, boneinfo.name.length); 66 | this.parent = boneinfo.parent; 67 | } 68 | 69 | public BoneInfo(APersistentMap map){ 70 | super(); 71 | Object name = map.get(Keyword.intern("name")); 72 | if(name == null) 73 | throw new IllegalArgumentException("Map needs key :name"); 74 | this.name = (byte[])name; 75 | Number parent = (Number)map.get(Keyword.intern("parent")); 76 | if(parent == null) 77 | throw new IllegalArgumentException("Map needs key :parent"); 78 | this.parent = parent.intValue(); 79 | } 80 | 81 | public BoneInfo(Object obj){ 82 | super(); 83 | if(obj instanceof BoneInfo){ 84 | BoneInfo b = (BoneInfo)obj; 85 | System.arraycopy(b.name, 0, this.name, 0, b.name.length); 86 | this.parent = b.parent; 87 | }else if(obj instanceof APersistentMap){ 88 | APersistentMap map = (APersistentMap)obj; 89 | Object name = map.get(Keyword.intern("name")); 90 | if(name == null) 91 | throw new IllegalArgumentException("Map needs key :name"); 92 | this.name = (byte[])name; 93 | Number parent = (Number)map.get(Keyword.intern("parent")); 94 | if(parent == null) 95 | throw new IllegalArgumentException("Map needs key :parent"); 96 | this.parent = parent.intValue(); 97 | }else{ 98 | throw new IllegalArgumentException("obj of unsupported type "+obj); 99 | } 100 | } 101 | 102 | public BoneInfo(){ 103 | super(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /java/raylib/jna/BoundingBox.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Vector3; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | import clojure.lang.APersistentVector; 9 | 10 | @FieldOrder({"min","max"}) 11 | public class BoundingBox extends Structure{ 12 | public static class ByValue extends BoundingBox implements Structure.ByValue{ 13 | public ByValue(){ 14 | super(); 15 | } 16 | 17 | public ByValue(APersistentMap map){ 18 | super(map); 19 | } 20 | public ByValue(Object obj){ 21 | super(obj); 22 | } 23 | } 24 | 25 | public Vector3 min; 26 | public Vector3 max; 27 | 28 | public BoundingBox(Vector3 min, Vector3 max){ 29 | super(); 30 | this.min = min; 31 | this.max = max; 32 | } 33 | 34 | public BoundingBox(BoundingBox bb){ 35 | this.min = new Vector3(bb.min); 36 | this.max = new Vector3(bb.max); 37 | } 38 | 39 | public BoundingBox(APersistentMap map){ 40 | super(); 41 | Object min = map.get(Keyword.intern("min")); 42 | if(min == null) 43 | throw new IllegalArgumentException("Map needs key :min"); 44 | if(min instanceof APersistentMap){ 45 | this.min = new Vector3((APersistentMap)min); 46 | } 47 | else if(min instanceof APersistentVector){ 48 | this.min = new Vector3((APersistentVector)min); 49 | } 50 | else if(min instanceof Vector3){ 51 | this.min = new Vector3((Vector3)min); 52 | } 53 | else{ 54 | throw new IllegalArgumentException(":min is of unsupported type"); 55 | } 56 | Object max = map.get(Keyword.intern("max")); 57 | if(max == null) 58 | throw new IllegalArgumentException("Map needs key :max"); 59 | if(max instanceof APersistentMap){ 60 | this.max = new Vector3((APersistentMap)max); 61 | } 62 | else if(max instanceof APersistentVector){ 63 | this.max = new Vector3((APersistentVector)max); 64 | } 65 | else if(max instanceof Vector3){ 66 | this.max = new Vector3((Vector3)max); 67 | } 68 | else{ 69 | throw new IllegalArgumentException(":max is of unsupported type"); 70 | } 71 | } 72 | 73 | 74 | public BoundingBox(Object obj){ 75 | super(); 76 | if(obj instanceof BoundingBox){ 77 | BoundingBox b = (BoundingBox)obj; 78 | this.min = new Vector3(b.min); 79 | this.max = new Vector3(b.max); 80 | }else if(obj instanceof APersistentMap){ 81 | APersistentMap map = (APersistentMap)obj; 82 | Object min = map.get(Keyword.intern("min")); 83 | if(min == null) 84 | throw new IllegalArgumentException("Map needs key :min"); 85 | if(min instanceof APersistentMap){ 86 | this.min = new Vector3((APersistentMap)min); 87 | } 88 | else if(min instanceof APersistentVector){ 89 | this.min = new Vector3((APersistentVector)min); 90 | } 91 | else if(min instanceof Vector3){ 92 | this.min = new Vector3((Vector3)min); 93 | } 94 | else{ 95 | throw new IllegalArgumentException(":min is of unsupported type"); 96 | } 97 | Object max = map.get(Keyword.intern("max")); 98 | if(max == null) 99 | throw new IllegalArgumentException("Map needs key :max"); 100 | if(max instanceof APersistentMap){ 101 | this.max = new Vector3((APersistentMap)max); 102 | } 103 | else if(max instanceof APersistentVector){ 104 | this.max = new Vector3((APersistentVector)max); 105 | } 106 | else if(max instanceof Vector3){ 107 | this.max = new Vector3((Vector3)max); 108 | } 109 | else{ 110 | throw new IllegalArgumentException(":max is of unsupported type"); 111 | } 112 | }else{ 113 | throw new IllegalArgumentException("obj of unsupported type "+obj); 114 | } 115 | } 116 | 117 | public BoundingBox(){ 118 | super(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /java/raylib/jna/Camera2D.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Vector2; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | import clojure.lang.APersistentVector; 9 | 10 | @FieldOrder({"offset","target","rotation","zoom"}) 11 | public class Camera2D extends Structure{ 12 | public static class ByValue extends Camera2D implements Structure.ByValue{ 13 | public ByValue(){ 14 | super(); 15 | } 16 | 17 | public ByValue(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByValue(Vector2 offset, Vector2 target, float rotation, float zoom){ 22 | super(offset, target, rotation, zoom); 23 | } 24 | 25 | public ByValue(Object obj){ 26 | super(obj); 27 | } 28 | } 29 | 30 | public Vector2 offset; 31 | public Vector2 target; 32 | public float rotation; 33 | public float zoom; 34 | 35 | public Camera2D(Vector2 offset, Vector2 target, float rotation, float zoom){ 36 | super(); 37 | this.offset = offset; 38 | this.target = target; 39 | this.rotation = rotation; 40 | this.zoom = zoom; 41 | } 42 | 43 | public Camera2D(Camera2D c2d){ 44 | super(); 45 | this.offset = new Vector2(c2d.offset); 46 | this.target = new Vector2(c2d.target); 47 | this.rotation = c2d.rotation; 48 | this.zoom = c2d.zoom; 49 | } 50 | 51 | public Camera2D(APersistentMap map){ 52 | super(); 53 | Object offset = map.get(Keyword.intern("offset")); 54 | if(offset == null) 55 | throw new IllegalArgumentException("Map needs key :offset"); 56 | if(offset instanceof APersistentMap){ 57 | this.offset = new Vector2((APersistentMap)offset); 58 | } 59 | else if(offset instanceof APersistentVector){ 60 | this.offset = new Vector2((APersistentVector)offset); 61 | } 62 | else if(offset instanceof Vector2){ 63 | this.offset = new Vector2((Vector2)offset); 64 | } 65 | else{ 66 | throw new IllegalArgumentException(":offset is of unsupported type"); 67 | } 68 | Object target = map.get(Keyword.intern("target")); 69 | if(target == null) 70 | throw new IllegalArgumentException("Map needs key :target"); 71 | if(target instanceof APersistentMap){ 72 | this.target = new Vector2((APersistentMap)target); 73 | } 74 | else if(target instanceof APersistentVector){ 75 | this.target = new Vector2((APersistentVector)target); 76 | } 77 | else if(target instanceof Vector2){ 78 | this.target = new Vector2((Vector2)target); 79 | } 80 | else{ 81 | throw new IllegalArgumentException(":target is of unsupported type"); 82 | } 83 | Number rotation = (Number)map.get(Keyword.intern("rotation")); 84 | if(rotation == null) 85 | throw new IllegalArgumentException("Map needs key :rotation"); 86 | this.rotation = rotation.floatValue(); 87 | Number zoom = (Number)map.get(Keyword.intern("zoom")); 88 | if(zoom == null) 89 | throw new IllegalArgumentException("Map needs key :zoom"); 90 | this.zoom = zoom.floatValue(); 91 | } 92 | 93 | public Camera2D(Object obj){ 94 | super(); 95 | if(obj instanceof Camera2D){ 96 | Camera2D c2d = (Camera2D)obj; 97 | this.offset = new Vector2(c2d.offset); 98 | this.target = new Vector2(c2d.target); 99 | this.rotation = c2d.rotation; 100 | this.zoom = c2d.zoom; 101 | }else if(obj instanceof APersistentMap){ 102 | APersistentMap map = (APersistentMap)obj; 103 | Object offset = map.get(Keyword.intern("offset")); 104 | if(offset == null) 105 | throw new IllegalArgumentException("Map needs key :offset"); 106 | if(offset instanceof APersistentMap){ 107 | this.offset = new Vector2((APersistentMap)offset); 108 | } 109 | else if(offset instanceof APersistentVector){ 110 | this.offset = new Vector2((APersistentVector)offset); 111 | } 112 | else if(offset instanceof Vector2){ 113 | this.offset = new Vector2((Vector2)offset); 114 | } 115 | else{ 116 | throw new IllegalArgumentException(":offset is of unsupported type"); 117 | } 118 | Object target = map.get(Keyword.intern("target")); 119 | if(target == null) 120 | throw new IllegalArgumentException("Map needs key :target"); 121 | if(target instanceof APersistentMap){ 122 | this.target = new Vector2((APersistentMap)target); 123 | } 124 | else if(target instanceof APersistentVector){ 125 | this.target = new Vector2((APersistentVector)target); 126 | } 127 | else if(target instanceof Vector2){ 128 | this.target = new Vector2((Vector2)target); 129 | } 130 | else{ 131 | throw new IllegalArgumentException(":target is of unsupported type"); 132 | } 133 | Number rotation = (Number)map.get(Keyword.intern("rotation")); 134 | if(rotation == null) 135 | throw new IllegalArgumentException("Map needs key :rotation"); 136 | this.rotation = rotation.floatValue(); 137 | Number zoom = (Number)map.get(Keyword.intern("zoom")); 138 | if(zoom == null) 139 | throw new IllegalArgumentException("Map needs key :zoom"); 140 | this.zoom = zoom.floatValue(); 141 | }else{ 142 | throw new IllegalArgumentException("obj of unsupported type "+obj); 143 | } 144 | } 145 | 146 | public Camera2D(){ 147 | super(); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /java/raylib/jna/Camera3D.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Vector3; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | import clojure.lang.APersistentVector; 9 | 10 | @FieldOrder({"position","target","up","fovy","type"}) 11 | public class Camera3D extends Structure{ 12 | public static class ByReference extends Camera3D implements Structure.ByReference{ 13 | public ByReference(Vector3 position, Vector3 target, Vector3 up, float fovy, int type){ 14 | super(position, target, up, fovy, type); 15 | } 16 | 17 | public ByReference(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByReference(){ 22 | super(); 23 | } 24 | 25 | public ByReference(ByValue b){ 26 | super(b); 27 | } 28 | public ByReference(Object obj){ 29 | super(obj); 30 | } 31 | 32 | } 33 | 34 | public static class ByValue extends Camera3D implements Structure.ByValue{ 35 | public ByValue(Vector3 position, Vector3 target, Vector3 up, float fovy, int type){ 36 | super(position, target, up, fovy, type); 37 | } 38 | 39 | public ByValue(APersistentMap map){ 40 | super(map); 41 | } 42 | 43 | public ByValue(){ 44 | super(); 45 | } 46 | 47 | public ByValue(ByReference b){ 48 | super(b); 49 | } 50 | 51 | public ByValue(Object obj){ 52 | super(obj); 53 | } 54 | } 55 | 56 | public Vector3 position; 57 | public Vector3 target; 58 | public Vector3 up; 59 | public float fovy; 60 | public int type; 61 | 62 | public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovy, int type){ 63 | super(); 64 | this.position = position; 65 | this.target = target; 66 | this.up = up; 67 | this.fovy = fovy; 68 | this.type = type; 69 | } 70 | 71 | public Camera3D(Camera3D c){ 72 | super(); 73 | this.position = new Vector3(c.position); 74 | this.target = new Vector3(c.target); 75 | this.up = new Vector3(c.up); 76 | this.fovy = c.fovy; 77 | this.type = c.type; 78 | } 79 | 80 | public Camera3D(APersistentMap map){ 81 | super(); 82 | Object position = map.get(Keyword.intern("position")); 83 | if(position == null) 84 | throw new IllegalArgumentException("Map needs key :position"); 85 | if(position instanceof APersistentMap){ 86 | this.position = new Vector3((APersistentMap)position); 87 | } 88 | else if(position instanceof APersistentVector){ 89 | this.position = new Vector3((APersistentVector)position); 90 | } 91 | else if(position instanceof Vector3){ 92 | this.position = new Vector3((Vector3)position); 93 | } 94 | else{ 95 | throw new IllegalArgumentException(":position is of unsupported type"); 96 | } 97 | Object target = map.get(Keyword.intern("target")); 98 | if(target == null) 99 | throw new IllegalArgumentException("Map needs key :target"); 100 | if(target instanceof APersistentMap){ 101 | this.target = new Vector3((APersistentMap)target); 102 | } 103 | else if(target instanceof APersistentVector){ 104 | this.target = new Vector3((APersistentVector)target); 105 | } 106 | else if(target instanceof Vector3){ 107 | this.target = new Vector3((Vector3)target); 108 | } 109 | else{ 110 | throw new IllegalArgumentException(":target is of unsupported type"); 111 | } 112 | Object up = map.get(Keyword.intern("up")); 113 | if(up == null) 114 | throw new IllegalArgumentException("Map needs key :up"); 115 | if(up instanceof APersistentMap){ 116 | this.up = new Vector3((APersistentMap)up); 117 | } 118 | else if(up instanceof APersistentVector){ 119 | this.up = new Vector3((APersistentVector)up); 120 | } 121 | else if(up instanceof Vector3){ 122 | this.up = new Vector3((Vector3)up); 123 | } 124 | else{ 125 | throw new IllegalArgumentException(":up is of unsupported type"); 126 | } 127 | Number fovy = (Number)map.get(Keyword.intern("fovy")); 128 | if(fovy == null) 129 | throw new IllegalArgumentException("Map needs key :fovy"); 130 | this.fovy = fovy.floatValue(); 131 | Number type = (Number)map.get(Keyword.intern("type")); 132 | if(type == null) 133 | throw new IllegalArgumentException("Map needs key :type"); 134 | this.type = type.intValue(); 135 | } 136 | 137 | public Camera3D(Object obj){ 138 | super(); 139 | if(obj instanceof Camera3D){ 140 | Camera3D c = (Camera3D)obj; 141 | this.position = new Vector3(c.position); 142 | this.target = new Vector3(c.target); 143 | this.up = new Vector3(c.up); 144 | this.fovy = c.fovy; 145 | this.type = c.type; 146 | }else if(obj instanceof APersistentMap){ 147 | APersistentMap map = (APersistentMap)obj; 148 | Object position = map.get(Keyword.intern("position")); 149 | if(position == null) 150 | throw new IllegalArgumentException("Map needs key :position"); 151 | if(position instanceof APersistentMap){ 152 | this.position = new Vector3((APersistentMap)position); 153 | } 154 | else if(position instanceof APersistentVector){ 155 | this.position = new Vector3((APersistentVector)position); 156 | } 157 | else if(position instanceof Vector3){ 158 | this.position = new Vector3((Vector3)position); 159 | } 160 | else{ 161 | throw new IllegalArgumentException(":position is of unsupported type"); 162 | } 163 | Object target = map.get(Keyword.intern("target")); 164 | if(target == null) 165 | throw new IllegalArgumentException("Map needs key :target"); 166 | if(target instanceof APersistentMap){ 167 | this.target = new Vector3((APersistentMap)target); 168 | } 169 | else if(target instanceof APersistentVector){ 170 | this.target = new Vector3((APersistentVector)target); 171 | } 172 | else if(target instanceof Vector3){ 173 | this.target = new Vector3((Vector3)target); 174 | } 175 | else{ 176 | throw new IllegalArgumentException(":target is of unsupported type"); 177 | } 178 | Object up = map.get(Keyword.intern("up")); 179 | if(up == null) 180 | throw new IllegalArgumentException("Map needs key :up"); 181 | if(up instanceof APersistentMap){ 182 | this.up = new Vector3((APersistentMap)up); 183 | } 184 | else if(up instanceof APersistentVector){ 185 | this.up = new Vector3((APersistentVector)up); 186 | } 187 | else if(up instanceof Vector3){ 188 | this.up = new Vector3((Vector3)up); 189 | } 190 | else{ 191 | throw new IllegalArgumentException(":up is of unsupported type"); 192 | } 193 | Number fovy = (Number)map.get(Keyword.intern("fovy")); 194 | if(fovy == null) 195 | throw new IllegalArgumentException("Map needs key :fovy"); 196 | this.fovy = fovy.floatValue(); 197 | Number type = (Number)map.get(Keyword.intern("type")); 198 | if(type == null) 199 | throw new IllegalArgumentException("Map needs key :type"); 200 | this.type = type.intValue(); 201 | }else{ 202 | throw new IllegalArgumentException("obj of unsupported type "+obj); 203 | } 204 | } 205 | public Camera3D(){ 206 | super(); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /java/raylib/jna/CharInfo.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Image; 6 | import clojure.lang.Keyword; 7 | import clojure.lang.APersistentMap; 8 | 9 | @FieldOrder({"value","offsetX","offsetY","advanceX","image"}) 10 | public class CharInfo extends Structure{ 11 | public static class ByReference extends CharInfo implements Structure.ByReference { 12 | public ByReference(int value, int offsetX, int offsetY, int advanceX, Image image){ 13 | super(value, offsetX, offsetY, advanceX, image); 14 | } 15 | 16 | public ByReference(){ 17 | super(); 18 | } 19 | 20 | public ByReference(APersistentMap map){ 21 | super(map); 22 | } 23 | 24 | public ByReference(ByValue ci){ 25 | super((CharInfo)ci); 26 | } 27 | 28 | public ByReference(ByReference ci){ 29 | super((CharInfo)ci); 30 | } 31 | public ByReference(Object obj){ 32 | super(obj); 33 | } 34 | } 35 | 36 | public static class ByValue extends CharInfo implements Structure.ByValue { 37 | public ByValue(int value, int offsetX, int offsetY, int advanceX, Image image){ 38 | super(value, offsetX, offsetY, advanceX, image); 39 | } 40 | 41 | public ByValue(){ 42 | super(); 43 | } 44 | 45 | public ByValue(APersistentMap map){ 46 | super(map); 47 | } 48 | 49 | public ByValue(ByReference ci){ 50 | super((CharInfo)ci); 51 | } 52 | public ByValue(Object obj){ 53 | super(obj); 54 | } 55 | } 56 | 57 | public int value; 58 | public int offsetX; 59 | public int offsetY; 60 | public int advanceX; 61 | public Image image; 62 | 63 | public CharInfo(APersistentMap map){ 64 | super(); 65 | Number value = (Number)map.get(Keyword.intern("value")); 66 | if(value == null) 67 | throw new IllegalArgumentException("Map needs key :value"); 68 | this.value = value.intValue(); 69 | Number offsetX = (Number)map.get(Keyword.intern("offsetX")); 70 | if(offsetX == null) 71 | throw new IllegalArgumentException("Map needs key :offsetX"); 72 | this.offsetX = offsetX.intValue(); 73 | Number offsetY = (Number)map.get(Keyword.intern("offsetY")); 74 | if(offsetY == null) 75 | throw new IllegalArgumentException("Map needs key :offsetY"); 76 | this.offsetY = offsetY.intValue(); 77 | Number advanceX = (Number)map.get(Keyword.intern("advanceX")); 78 | if(advanceX == null) 79 | throw new IllegalArgumentException("Map needs key :advanceX"); 80 | this.advanceX = advanceX.intValue(); 81 | Object image = map.get(Keyword.intern("image")); 82 | if(image == null) 83 | throw new IllegalArgumentException("Map needs key :image"); 84 | if(image instanceof APersistentMap){ 85 | this.image = new Image((APersistentMap)image); 86 | } 87 | else if(image instanceof Image){ 88 | this.image = new Image((Image)image); 89 | } 90 | else{ 91 | throw new IllegalArgumentException(":image is of unsupported type"); 92 | } 93 | } 94 | 95 | public CharInfo(int value, int offsetX, int offsetY, int advanceX, Image image){ 96 | super(); 97 | this.value = value; 98 | this.offsetX = offsetX; 99 | this.offsetY = offsetY; 100 | this.advanceX = advanceX; 101 | this.image = image; 102 | } 103 | 104 | public CharInfo(CharInfo ci){ 105 | super(); 106 | this.value = ci.value; 107 | this.offsetX = ci.offsetX; 108 | this.offsetY = ci.offsetY; 109 | this.advanceX = ci.advanceX; 110 | this.image = new Image(ci.image); 111 | } 112 | 113 | public CharInfo(Object obj){ 114 | super(); 115 | if(obj instanceof CharInfo){ 116 | CharInfo ci = (CharInfo)obj; 117 | 118 | this.value = ci.value; 119 | this.offsetX = ci.offsetX; 120 | this.offsetY = ci.offsetY; 121 | this.advanceX = ci.advanceX; 122 | this.image = new Image(ci.image); 123 | }else if(obj instanceof APersistentMap){ 124 | APersistentMap map = (APersistentMap)obj; 125 | Number value = (Number)map.get(Keyword.intern("value")); 126 | if(value == null) 127 | throw new IllegalArgumentException("Map needs key :value"); 128 | this.value = value.intValue(); 129 | Number offsetX = (Number)map.get(Keyword.intern("offsetX")); 130 | if(offsetX == null) 131 | throw new IllegalArgumentException("Map needs key :offsetX"); 132 | this.offsetX = offsetX.intValue(); 133 | Number offsetY = (Number)map.get(Keyword.intern("offsetY")); 134 | if(offsetY == null) 135 | throw new IllegalArgumentException("Map needs key :offsetY"); 136 | this.offsetY = offsetY.intValue(); 137 | Number advanceX = (Number)map.get(Keyword.intern("advanceX")); 138 | if(advanceX == null) 139 | throw new IllegalArgumentException("Map needs key :advanceX"); 140 | this.advanceX = advanceX.intValue(); 141 | Object image = map.get(Keyword.intern("image")); 142 | if(image == null) 143 | throw new IllegalArgumentException("Map needs key :image"); 144 | if(image instanceof APersistentMap){ 145 | this.image = new Image((APersistentMap)image); 146 | } 147 | else if(image instanceof Image){ 148 | this.image = new Image((Image)image); 149 | } 150 | else{ 151 | throw new IllegalArgumentException(":image is of unsupported type"); 152 | } 153 | }else{ 154 | throw new IllegalArgumentException("obj of unsupported type "+obj); 155 | } 156 | } 157 | 158 | public CharInfo(){ 159 | super(); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /java/raylib/jna/Color.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.Keyword; 6 | import clojure.lang.APersistentMap; 7 | 8 | @FieldOrder({"r","g","b","a"}) 9 | public class Color extends Structure{ 10 | public static class ByReference extends Color implements Structure.ByReference{ 11 | public ByReference(){ 12 | super(); 13 | } 14 | 15 | public ByReference(byte r, byte g, byte b, byte a){ 16 | super(r,g,b,a); 17 | } 18 | 19 | public ByReference(APersistentMap map){ 20 | super(map); 21 | } 22 | 23 | public ByReference(ByValue br){ 24 | super(br); 25 | } 26 | 27 | public ByReference(int r, int g, int b, int a){ 28 | super(r,g,b,a); 29 | } 30 | 31 | public ByReference(Object obj){ 32 | super(obj); 33 | } 34 | } 35 | 36 | public static class ByValue extends Color implements Structure.ByValue{ 37 | public ByValue(){ 38 | super(); 39 | } 40 | 41 | public ByValue(byte r, byte g, byte b, byte a){ 42 | super(r,g,b,a); 43 | } 44 | 45 | public ByValue(APersistentMap map){ 46 | super(map); 47 | } 48 | 49 | public ByValue(ByReference br){ 50 | super(br); 51 | } 52 | 53 | public ByValue(int r, int g, int b, int a){ 54 | super(r,g,b,a); 55 | } 56 | 57 | public ByValue(Object obj){ 58 | super(obj); 59 | } 60 | } 61 | 62 | public byte r; 63 | public byte g; 64 | public byte b; 65 | public byte a; 66 | 67 | public Color(byte r, byte g, byte b, byte a){ 68 | super(); 69 | this.r = r; 70 | this.g = g; 71 | this.b = b; 72 | this.a = a; 73 | } 74 | 75 | public Color(int r, int g, int b, int a){ 76 | super(); 77 | this.r = intToByte(r); 78 | this.g = intToByte(g); 79 | this.b = intToByte(b); 80 | this.a = intToByte(a); 81 | } 82 | 83 | public Color(Color c){ 84 | super(); 85 | this.r = c.r; 86 | this.g = c.g; 87 | this.b = c.b; 88 | this.a = c.a; 89 | } 90 | 91 | public Color(APersistentMap map){ 92 | super(); 93 | Number r = (Number)map.get(Keyword.intern("r")); 94 | if(r == null) 95 | throw new IllegalArgumentException("Map needs key :r"); 96 | this.r = r.byteValue(); 97 | Number g = (Number)map.get(Keyword.intern("g")); 98 | if(g == null) 99 | throw new IllegalArgumentException("Map needs key :g"); 100 | this.g = g.byteValue(); 101 | Number b = (Number)map.get(Keyword.intern("b")); 102 | if(b == null) 103 | throw new IllegalArgumentException("Map needs key :b"); 104 | this.b = b.byteValue(); 105 | Number a = (Number)map.get(Keyword.intern("a")); 106 | if(a == null) 107 | throw new IllegalArgumentException("Map needs key :a"); 108 | this.a = a.byteValue(); 109 | } 110 | 111 | public Color(Object obj) throws IllegalArgumentException{ 112 | super(); 113 | if(obj instanceof Color){ 114 | Color c = (Color)obj; 115 | this.r = c.r; 116 | this.g = c.g; 117 | this.b = c.b; 118 | this.a = c.a; 119 | }else if(obj instanceof APersistentMap){ 120 | APersistentMap map = (APersistentMap)obj; 121 | Number r = (Number)map.get(Keyword.intern("r")); 122 | if(r == null) 123 | throw new IllegalArgumentException("Map needs key :r"); 124 | this.r = r.byteValue(); 125 | Number g = (Number)map.get(Keyword.intern("g")); 126 | if(g == null) 127 | throw new IllegalArgumentException("Map needs key :g"); 128 | this.g = g.byteValue(); 129 | Number b = (Number)map.get(Keyword.intern("b")); 130 | if(b == null) 131 | throw new IllegalArgumentException("Map needs key :b"); 132 | this.b = b.byteValue(); 133 | Number a = (Number)map.get(Keyword.intern("a")); 134 | if(a == null) 135 | throw new IllegalArgumentException("Map needs key :a"); 136 | this.a = a.byteValue(); 137 | }else{ 138 | throw new IllegalArgumentException("obj of unsupported type "+obj); 139 | } 140 | } 141 | 142 | public Color(){ 143 | super(); 144 | } 145 | 146 | public static byte intToByte(final int data) throws IllegalArgumentException{ 147 | if(data > 255 || data < 0) 148 | throw new IllegalArgumentException("Data argument must be between 0 and 255"); 149 | return (byte)((data >> 0) & 0xff); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /java/raylib/jna/Font.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Texture2D; 6 | import raylib.jna.Rectangle; 7 | import raylib.jna.CharInfo; 8 | import clojure.lang.APersistentMap; 9 | import clojure.lang.Keyword; 10 | 11 | @FieldOrder({"baseSize","charsCount","texture","recs","chars"}) 12 | public class Font extends Structure{ 13 | public static class ByValue extends Font implements Structure.ByValue{ 14 | public ByValue(){ 15 | super(); 16 | } 17 | 18 | public ByValue(APersistentMap map){ 19 | super(map); 20 | } 21 | 22 | public ByValue(int baseSize, int charsCount, Texture2D texture, Rectangle.ByReference recs, CharInfo.ByReference chars){ 23 | super(baseSize, charsCount, texture, recs, chars); 24 | } 25 | public ByValue(Object obj){ 26 | super(obj); 27 | } 28 | } 29 | 30 | 31 | public int baseSize; 32 | public int charsCount; 33 | public Texture2D texture; 34 | public Rectangle.ByReference recs; 35 | public CharInfo.ByReference chars; 36 | 37 | public Font(APersistentMap map){ 38 | super(); 39 | Number baseSize = (Number)map.get(Keyword.intern("baseSize")); 40 | if(baseSize == null) 41 | throw new IllegalArgumentException("Map needs key :baseSize"); 42 | this.baseSize = baseSize.intValue(); 43 | Number charsCount = (Number)map.get(Keyword.intern("charsCount")); 44 | if(charsCount == null) 45 | throw new IllegalArgumentException("Map needs key :charsCount"); 46 | this.charsCount = charsCount.intValue(); 47 | Object texture = map.get(Keyword.intern("texture")); 48 | if(texture == null) 49 | throw new IllegalArgumentException("Map needs key :texture"); 50 | if(texture instanceof APersistentMap){ 51 | this.texture = new Texture2D((APersistentMap)texture); 52 | } 53 | else if(texture instanceof Texture2D){ 54 | this.texture = new Texture2D((Texture2D)texture); 55 | } 56 | else{ 57 | throw new IllegalArgumentException(":min is of unsupported type"); 58 | } 59 | Object recs = map.get(Keyword.intern("recs")); 60 | if(recs == null) 61 | throw new IllegalArgumentException("Map needs key :recs"); 62 | if(recs instanceof APersistentMap){ 63 | this.recs = new Rectangle.ByReference((APersistentMap)recs); 64 | } 65 | else if(recs instanceof Rectangle.ByReference){ 66 | this.recs = new Rectangle.ByReference((Rectangle.ByReference)recs); 67 | } 68 | else{ 69 | throw new IllegalArgumentException(":recs is of unsupported type"); 70 | } 71 | } 72 | 73 | public Font(Font f){ 74 | super(); 75 | this.baseSize = f.baseSize; 76 | this.charsCount = f.charsCount; 77 | this.texture = new Texture2D(f.texture); 78 | this.recs = new Rectangle.ByReference(recs); 79 | this.chars = new CharInfo.ByReference(chars); 80 | } 81 | 82 | 83 | public Font(Object obj){ 84 | super(); 85 | if(obj instanceof Font){ 86 | Font f = (Font)obj; 87 | this.baseSize = f.baseSize; 88 | this.charsCount = f.charsCount; 89 | this.texture = new Texture2D(f.texture); 90 | this.recs = new Rectangle.ByReference(recs); 91 | this.chars = new CharInfo.ByReference(chars); 92 | }else if(obj instanceof APersistentMap){ 93 | APersistentMap map = (APersistentMap)obj; 94 | Number baseSize = (Number)map.get(Keyword.intern("baseSize")); 95 | if(baseSize == null) 96 | throw new IllegalArgumentException("Map needs key :baseSize"); 97 | this.baseSize = baseSize.intValue(); 98 | Number charsCount = (Number)map.get(Keyword.intern("charsCount")); 99 | if(charsCount == null) 100 | throw new IllegalArgumentException("Map needs key :charsCount"); 101 | this.charsCount = charsCount.intValue(); 102 | Object texture = map.get(Keyword.intern("texture")); 103 | if(texture == null) 104 | throw new IllegalArgumentException("Map needs key :texture"); 105 | if(texture instanceof APersistentMap){ 106 | this.texture = new Texture2D((APersistentMap)texture); 107 | } 108 | else if(texture instanceof Texture2D){ 109 | this.texture = new Texture2D((Texture2D)texture); 110 | } 111 | else{ 112 | throw new IllegalArgumentException(":min is of unsupported type"); 113 | } 114 | Object recs = map.get(Keyword.intern("recs")); 115 | if(recs == null) 116 | throw new IllegalArgumentException("Map needs key :recs"); 117 | if(recs instanceof APersistentMap){ 118 | this.recs = new Rectangle.ByReference((APersistentMap)recs); 119 | } 120 | else if(recs instanceof Rectangle.ByReference){ 121 | this.recs = new Rectangle.ByReference((Rectangle.ByReference)recs); 122 | } 123 | else{ 124 | throw new IllegalArgumentException(":recs is of unsupported type"); 125 | } 126 | }else{ 127 | throw new IllegalArgumentException("obj of unsupported type "+obj); 128 | } 129 | } 130 | 131 | public Font(int baseSize, int charsCount, Texture2D texture, Rectangle.ByReference recs, CharInfo.ByReference chars){ 132 | super(); 133 | this.baseSize = baseSize; 134 | this.charsCount = charsCount; 135 | this.texture = texture; 136 | this.recs = recs; 137 | this.chars = chars; 138 | } 139 | 140 | public Font(){ 141 | super(); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /java/raylib/jna/Image.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.Pointer; 6 | import clojure.lang.Keyword; 7 | import clojure.lang.APersistentMap; 8 | 9 | @FieldOrder({"data","width","height","mipmaps","format"}) 10 | public class Image extends Structure{ 11 | public static class ByReference extends Image implements Structure.ByReference{ 12 | public ByReference(Pointer data, int width, int height, int mipmaps, int format){ 13 | super(data, width, height, mipmaps, format); 14 | } 15 | 16 | public ByReference(){ 17 | super(); 18 | } 19 | 20 | public ByReference(APersistentMap map){ 21 | super(map); 22 | } 23 | 24 | public ByReference(ByValue br){ 25 | super((Image)br); 26 | } 27 | public ByReference(Object obj){ 28 | super(obj); 29 | } 30 | } 31 | 32 | public static class ByValue extends Image implements Structure.ByValue{ 33 | public ByValue(Pointer data, int width, int height, int mipmaps, int format){ 34 | super(data, width, height, mipmaps, format); 35 | } 36 | 37 | public ByValue(){ 38 | super(); 39 | } 40 | 41 | public ByValue(APersistentMap map){ 42 | super(map); 43 | } 44 | 45 | public ByValue(ByReference br){ 46 | super((Image)br); 47 | } 48 | public ByValue(Object obj){ 49 | super(obj); 50 | } 51 | } 52 | 53 | public Pointer data; 54 | public int width; 55 | public int height; 56 | public int mipmaps; 57 | public int format; 58 | 59 | public Image(Pointer data, int width, int height, int mipmaps, int format){ 60 | super(); 61 | this.data = data; 62 | this.width = width; 63 | this.height = height; 64 | this.mipmaps = mipmaps; 65 | this.format = format; 66 | } 67 | 68 | public Image(Image img){ 69 | super(); 70 | this.data = img.data; 71 | this.width = img.width; 72 | this.height = img.height; 73 | this.mipmaps = img.mipmaps; 74 | this.format = img.format; 75 | } 76 | 77 | public Image(APersistentMap map){ 78 | super(); 79 | Pointer data = (Pointer)map.get(Keyword.intern("data")); 80 | if(data == null) 81 | throw new IllegalArgumentException("Map needs key :data"); 82 | this.data = data; 83 | Number width = (Number)map.get(Keyword.intern("width")); 84 | if(width == null) 85 | throw new IllegalArgumentException("Map needs key :width"); 86 | this.width = width.intValue(); 87 | Number height = (Number)map.get(Keyword.intern("height")); 88 | if(height == null) 89 | throw new IllegalArgumentException("Map needs key :height"); 90 | this.height = height.intValue(); 91 | Number mipmaps = (Number)map.get(Keyword.intern("mipmaps")); 92 | if(mipmaps == null) 93 | throw new IllegalArgumentException("Map needs key :mipmaps"); 94 | this.mipmaps = mipmaps.intValue(); 95 | Number format = (Number)map.get(Keyword.intern("format")); 96 | if(format == null) 97 | throw new IllegalArgumentException("Map needs key :format"); 98 | this.format = format.intValue(); 99 | } 100 | 101 | public Image(Object obj){ 102 | super(); 103 | if(obj instanceof Image){ 104 | Image img = (Image)obj; 105 | this.data = img.data; 106 | this.width = img.width; 107 | this.height = img.height; 108 | this.mipmaps = img.mipmaps; 109 | this.format = img.format; 110 | }else if(obj instanceof APersistentMap){ 111 | APersistentMap map = (APersistentMap)obj; 112 | Pointer data = (Pointer)map.get(Keyword.intern("data")); 113 | if(data == null) 114 | throw new IllegalArgumentException("Map needs key :data"); 115 | this.data = data; 116 | Number width = (Number)map.get(Keyword.intern("width")); 117 | if(width == null) 118 | throw new IllegalArgumentException("Map needs key :width"); 119 | this.width = width.intValue(); 120 | Number height = (Number)map.get(Keyword.intern("height")); 121 | if(height == null) 122 | throw new IllegalArgumentException("Map needs key :height"); 123 | this.height = height.intValue(); 124 | Number mipmaps = (Number)map.get(Keyword.intern("mipmaps")); 125 | if(mipmaps == null) 126 | throw new IllegalArgumentException("Map needs key :mipmaps"); 127 | this.mipmaps = mipmaps.intValue(); 128 | Number format = (Number)map.get(Keyword.intern("format")); 129 | if(format == null) 130 | throw new IllegalArgumentException("Map needs key :format"); 131 | this.format = format.intValue(); 132 | }else{ 133 | throw new IllegalArgumentException("obj of unsupported type "+obj); 134 | } 135 | } 136 | 137 | public Image(){ 138 | super(); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /java/raylib/jna/Material.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.ptr.FloatByReference; 6 | import raylib.jna.MaterialMap; 7 | import raylib.jna.Shader; 8 | import clojure.lang.APersistentMap; 9 | import clojure.lang.Keyword; 10 | 11 | @FieldOrder({"shader","maps","value"}) 12 | public class Material extends Structure{ 13 | public static class ByReference extends Material implements Structure.ByReference{ 14 | public ByReference(Texture2D shader, MaterialMap.ByReference maps, FloatByReference value){ 15 | super(shader, maps, value); 16 | } 17 | 18 | public ByReference(){ 19 | super(); 20 | } 21 | 22 | public ByReference(APersistentMap map){ 23 | super(map); 24 | } 25 | 26 | public ByReference(ByValue br){ 27 | super((Material)br); 28 | } 29 | 30 | public ByReference(ByReference br){ 31 | super((Material)br); 32 | } 33 | public ByReference(Object obj){ 34 | super(obj); 35 | } 36 | } 37 | 38 | public static class ByValue extends Material implements Structure.ByValue{ 39 | public ByValue(Texture2D shader, MaterialMap.ByReference maps, FloatByReference value){ 40 | super(shader, maps, value); 41 | } 42 | 43 | public ByValue(){ 44 | super(); 45 | } 46 | 47 | public ByValue(APersistentMap map){ 48 | super(map); 49 | } 50 | 51 | public ByValue(ByReference br){ 52 | super((Material)br); 53 | } 54 | public ByValue(Object obj){ 55 | super(obj); 56 | } 57 | } 58 | 59 | public Texture2D shader; 60 | public MaterialMap.ByReference maps; 61 | public FloatByReference value; 62 | 63 | public Material(Texture2D shader, MaterialMap.ByReference maps, FloatByReference value){ 64 | super(); 65 | this.shader = shader; 66 | this.maps = maps; 67 | this.value = value; 68 | } 69 | 70 | public Material(Material m){ 71 | super(); 72 | this.shader = new Texture2D(shader); 73 | this.maps = new MaterialMap.ByReference(maps); 74 | this.value = value; 75 | } 76 | 77 | public Material(APersistentMap map){ 78 | super(); 79 | Object shader = map.get(Keyword.intern("shader")); 80 | if(shader == null) 81 | throw new IllegalArgumentException("Map needs key :shader"); 82 | if(shader instanceof APersistentMap){ 83 | this.shader = new Texture2D((APersistentMap)shader); 84 | } 85 | else if(shader instanceof Texture2D){ 86 | this.shader = new Texture2D((Texture2D)shader); 87 | } 88 | else{ 89 | throw new IllegalArgumentException(":shader is of unsupported type"); 90 | } 91 | Object maps = map.get(Keyword.intern("maps")); 92 | if(maps == null) 93 | throw new IllegalArgumentException("Map needs key :maps"); 94 | if(maps instanceof APersistentMap){ 95 | this.maps = new MaterialMap.ByReference((APersistentMap)maps); 96 | } 97 | else if(maps instanceof MaterialMap.ByReference){ 98 | this.maps = new MaterialMap.ByReference((MaterialMap.ByReference)maps); 99 | } 100 | else{ 101 | throw new IllegalArgumentException(":maps is of unsupported type"); 102 | } 103 | } 104 | 105 | public Material(Object obj){ 106 | super(); 107 | if(obj instanceof Material){ 108 | Material b = (Material)obj; 109 | this.shader = new Texture2D(shader); 110 | this.maps = new MaterialMap.ByReference(maps); 111 | this.value = value; 112 | }else if(obj instanceof APersistentMap){ 113 | APersistentMap map = (APersistentMap)obj; 114 | Object shader = map.get(Keyword.intern("shader")); 115 | if(shader == null) 116 | throw new IllegalArgumentException("Map needs key :shader"); 117 | if(shader instanceof APersistentMap){ 118 | this.shader = new Texture2D((APersistentMap)shader); 119 | } 120 | else if(shader instanceof Texture2D){ 121 | this.shader = new Texture2D((Texture2D)shader); 122 | } 123 | else{ 124 | throw new IllegalArgumentException(":shader is of unsupported type"); 125 | } 126 | Object maps = map.get(Keyword.intern("maps")); 127 | if(maps == null) 128 | throw new IllegalArgumentException("Map needs key :maps"); 129 | if(maps instanceof APersistentMap){ 130 | this.maps = new MaterialMap.ByReference((APersistentMap)maps); 131 | } 132 | else if(maps instanceof MaterialMap.ByReference){ 133 | this.maps = new MaterialMap.ByReference((MaterialMap.ByReference)maps); 134 | } 135 | else{ 136 | throw new IllegalArgumentException(":maps is of unsupported type"); 137 | } 138 | }else{ 139 | throw new IllegalArgumentException("obj of unsupported type "+obj); 140 | } 141 | } 142 | 143 | public Material(){ 144 | super(); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /java/raylib/jna/MaterialMap.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Texture2D; 6 | import raylib.jna.Color; 7 | import clojure.lang.APersistentMap; 8 | import clojure.lang.Keyword; 9 | 10 | @FieldOrder({"texture","color","value"}) 11 | public class MaterialMap extends Structure{ 12 | public static class ByReference extends MaterialMap implements Structure.ByReference { 13 | public ByReference(Texture2D texture, Color color, float value){ 14 | super(texture, color, value); 15 | } 16 | 17 | public ByReference(){ 18 | super(); 19 | } 20 | 21 | public ByReference(APersistentMap map){ 22 | super(map); 23 | } 24 | 25 | public ByReference(ByReference br){ 26 | super((MaterialMap)br); 27 | } 28 | 29 | public ByReference(ByValue br){ 30 | super((MaterialMap)br); 31 | } 32 | public ByReference(Object obj){ 33 | super(obj); 34 | } 35 | } 36 | 37 | public static class ByValue extends MaterialMap implements Structure.ByValue { 38 | public ByValue(Texture2D texture, Color color, float value){ 39 | super(texture, color, value); 40 | } 41 | 42 | public ByValue(){ 43 | super(); 44 | } 45 | 46 | public ByValue(APersistentMap map){ 47 | super(map); 48 | } 49 | 50 | public ByValue(ByReference br){ 51 | super((MaterialMap)br); 52 | } 53 | public ByValue(Object obj){ 54 | super(obj); 55 | } 56 | } 57 | 58 | public Texture2D texture; 59 | public Color color; 60 | public float value; 61 | 62 | public MaterialMap(Texture2D texture, Color color, float value){ 63 | super(); 64 | this.texture = texture; 65 | this.color = color; 66 | this.value = value; 67 | } 68 | 69 | public MaterialMap(MaterialMap mm){ 70 | super(); 71 | this.texture = new Texture2D(mm.texture); 72 | this.color = new Color(mm.color); 73 | this.value = mm.value; 74 | } 75 | 76 | 77 | public MaterialMap(APersistentMap map){ 78 | super(); 79 | Object texture = map.get(Keyword.intern("texture")); 80 | if(texture == null) 81 | throw new IllegalArgumentException("Map needs key :texture"); 82 | if(texture instanceof APersistentMap){ 83 | this.texture = new Texture2D((APersistentMap)texture); 84 | } 85 | else if(texture instanceof Texture2D){ 86 | this.texture = new Texture2D((Texture2D)texture); 87 | } 88 | else{ 89 | throw new IllegalArgumentException(":texture is of unsupported type"); 90 | } 91 | Object color = map.get(Keyword.intern("color")); 92 | if(color == null) 93 | throw new IllegalArgumentException("Map needs key :color"); 94 | if(color instanceof APersistentMap){ 95 | this.color = new Color((APersistentMap)color); 96 | } 97 | else if(color instanceof Color){ 98 | this.color = new Color((Color)color); 99 | } 100 | else{ 101 | throw new IllegalArgumentException(":color is of unsupported type"); 102 | } 103 | Number value = (Number)map.get(Keyword.intern("value")); 104 | if(value == null) 105 | throw new IllegalArgumentException("Map needs key :value"); 106 | this.value = value.floatValue(); 107 | } 108 | 109 | public MaterialMap(Object obj){ 110 | super(); 111 | if(obj instanceof MaterialMap){ 112 | MaterialMap mm = (MaterialMap)obj; 113 | this.texture = new Texture2D(mm.texture); 114 | this.color = new Color(mm.color); 115 | this.value = mm.value; 116 | }else if(obj instanceof APersistentMap){ 117 | APersistentMap map = (APersistentMap)obj; 118 | Object texture = map.get(Keyword.intern("texture")); 119 | if(texture == null) 120 | throw new IllegalArgumentException("Map needs key :texture"); 121 | if(texture instanceof APersistentMap){ 122 | this.texture = new Texture2D((APersistentMap)texture); 123 | } 124 | else if(texture instanceof Texture2D){ 125 | this.texture = new Texture2D((Texture2D)texture); 126 | } 127 | else{ 128 | throw new IllegalArgumentException(":texture is of unsupported type"); 129 | } 130 | Object color = map.get(Keyword.intern("color")); 131 | if(color == null) 132 | throw new IllegalArgumentException("Map needs key :color"); 133 | if(color instanceof APersistentMap){ 134 | this.color = new Color((APersistentMap)color); 135 | } 136 | else if(color instanceof Color){ 137 | this.color = new Color((Color)color); 138 | } 139 | else{ 140 | throw new IllegalArgumentException(":color is of unsupported type"); 141 | } 142 | Number value = (Number)map.get(Keyword.intern("value")); 143 | if(value == null) 144 | throw new IllegalArgumentException("Map needs key :value"); 145 | this.value = value.floatValue(); 146 | }else{ 147 | throw new IllegalArgumentException("obj of unsupported type "+obj); 148 | } 149 | } 150 | 151 | public MaterialMap(){ 152 | super(); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /java/raylib/jna/Matrix.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentVector; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"m0","m4","m8","m12", 10 | "m1","m5","m9","m13", 11 | "m2","m6","m10","m14", 12 | "m3","m7","m11","m15"}) 13 | public class Matrix extends Structure{ 14 | public static class ByValue extends Matrix implements Structure.ByValue{ 15 | public ByValue(){ 16 | super(); 17 | } 18 | 19 | public ByValue(APersistentMap map){ 20 | super(map); 21 | } 22 | 23 | public ByValue(APersistentVector v){ 24 | super(v); 25 | } 26 | 27 | public ByValue(float m0, float m4, float m8, float m12, 28 | float m1, float m5, float m9, float m13, 29 | float m2, float m6, float m10, float m14, 30 | float m3, float m7, float m11, float m15){ 31 | super( m0, m4, m8, m12, 32 | m1, m5, m9, m13, 33 | m2, m6, m10, m14, 34 | m3, m7, m11, m15); 35 | } 36 | public ByValue(Object obj){ 37 | super(obj); 38 | } 39 | } 40 | public float m0, m4, m8, m12; 41 | public float m1, m5, m9, m13; 42 | public float m2, m6, m10, m14; 43 | public float m3, m7, m11, m15; 44 | 45 | public Matrix(float m0, float m4, float m8, float m12, 46 | float m1, float m5, float m9, float m13, 47 | float m2, float m6, float m10, float m14, 48 | float m3, float m7, float m11, float m15){ 49 | super(); 50 | this.m0 = m0; 51 | this.m1 = m1; 52 | this.m2 = m2; 53 | this.m3 = m3; 54 | this.m4 = m4; 55 | this.m5 = m5; 56 | this.m6 = m6; 57 | this.m7 = m7; 58 | this.m8 = m8; 59 | this.m9 = m9; 60 | this.m10 = m10; 61 | this.m11 = m11; 62 | this.m12 = m12; 63 | this.m13 = m13; 64 | this.m14 = m14; 65 | this.m15 = m15; 66 | } 67 | 68 | public Matrix(APersistentVector vec){ 69 | super(); 70 | if(vec.count() != 16) 71 | throw new IllegalArgumentException("PersistentVector needs to be of size 16"); 72 | this.m0 = ((Number)vec.get(0)).floatValue(); 73 | this.m4 = ((Number)vec.get(1)).floatValue(); 74 | this.m8 = ((Number)vec.get(2)).floatValue(); 75 | this.m12 = ((Number)vec.get(3)).floatValue(); 76 | this.m1 = ((Number)vec.get(4)).floatValue(); 77 | this.m5 = ((Number)vec.get(5)).floatValue(); 78 | this.m9 = ((Number)vec.get(6)).floatValue(); 79 | this.m13 = ((Number)vec.get(7)).floatValue(); 80 | this.m2 = ((Number)vec.get(8)).floatValue(); 81 | this.m6 = ((Number)vec.get(9)).floatValue(); 82 | this.m10 = ((Number)vec.get(10)).floatValue(); 83 | this.m14 = ((Number)vec.get(11)).floatValue(); 84 | this.m3 = ((Number)vec.get(12)).floatValue(); 85 | this.m7 = ((Number)vec.get(13)).floatValue(); 86 | this.m11 = ((Number)vec.get(14)).floatValue(); 87 | this.m15 = ((Number)vec.get(15)).floatValue(); 88 | } 89 | 90 | public Matrix(Matrix m){ 91 | super(); 92 | this.m0 = m.m0; 93 | this.m1 = m.m1; 94 | this.m2 = m.m2; 95 | this.m3 = m.m3; 96 | this.m4 = m.m4; 97 | this.m5 = m.m5; 98 | this.m6 = m.m6; 99 | this.m7 = m.m7; 100 | this.m8 = m.m8; 101 | this.m9 = m.m9; 102 | this.m10 = m.m10; 103 | this.m11 = m.m11; 104 | this.m12 = m.m12; 105 | this.m13 = m.m13; 106 | this.m14 = m.m14; 107 | this.m15 = m.m15; 108 | 109 | } 110 | 111 | public Matrix(APersistentMap map){ 112 | super(); 113 | Number m0 = (Number)map.get(Keyword.intern("m0")); 114 | if(m0 == null) 115 | throw new IllegalArgumentException("Map needs key :m0"); 116 | this.m0 = m0.floatValue(); 117 | Number m1 = (Number)map.get(Keyword.intern("m1")); 118 | if(m1 == null) 119 | throw new IllegalArgumentException("Map needs key :m1"); 120 | this.m1 = m1.floatValue(); 121 | Number m2 = (Number)map.get(Keyword.intern("m2")); 122 | if(m2 == null) 123 | throw new IllegalArgumentException("Map needs key :m2"); 124 | this.m2 = m2.floatValue(); 125 | Number m3 = (Number)map.get(Keyword.intern("m3")); 126 | if(m3 == null) 127 | throw new IllegalArgumentException("Map needs key :m3"); 128 | this.m3 = m3.floatValue(); 129 | Number m4 = (Number)map.get(Keyword.intern("m4")); 130 | if(m4 == null) 131 | throw new IllegalArgumentException("Map needs key :m4"); 132 | this.m4 = m4.floatValue(); 133 | Number m5 = (Number)map.get(Keyword.intern("m5")); 134 | if(m5 == null) 135 | throw new IllegalArgumentException("Map needs key :m5"); 136 | this.m5 = m5.floatValue(); 137 | Number m6 = (Number)map.get(Keyword.intern("m6")); 138 | if(m6 == null) 139 | throw new IllegalArgumentException("Map needs key :m6"); 140 | this.m6 = m6.floatValue(); 141 | Number m7 = (Number)map.get(Keyword.intern("m7")); 142 | if(m7 == null) 143 | throw new IllegalArgumentException("Map needs key :m7"); 144 | this.m7 = m7.floatValue(); 145 | Number m8 = (Number)map.get(Keyword.intern("m8")); 146 | if(m8 == null) 147 | throw new IllegalArgumentException("Map needs key :m8"); 148 | this.m8 = m8.floatValue(); 149 | Number m9 = (Number)map.get(Keyword.intern("m9")); 150 | if(m9 == null) 151 | throw new IllegalArgumentException("Map needs key :m9"); 152 | this.m9 = m9.floatValue(); 153 | Number m10 = (Number)map.get(Keyword.intern("m10")); 154 | if(m10 == null) 155 | throw new IllegalArgumentException("Map needs key :m10"); 156 | this.m10 = m10.floatValue(); 157 | Number m11 = (Number)map.get(Keyword.intern("m11")); 158 | if(m11 == null) 159 | throw new IllegalArgumentException("Map needs key :m11"); 160 | this.m11 = m11.floatValue(); 161 | Number m12 = (Number)map.get(Keyword.intern("m12")); 162 | if(m12 == null) 163 | throw new IllegalArgumentException("Map needs key :m12"); 164 | this.m12 = m12.floatValue(); 165 | Number m13 = (Number)map.get(Keyword.intern("m13")); 166 | if(m13 == null) 167 | throw new IllegalArgumentException("Map needs key :m13"); 168 | this.m13 = m13.floatValue(); 169 | Number m14 = (Number)map.get(Keyword.intern("m14")); 170 | if(m14 == null) 171 | throw new IllegalArgumentException("Map needs key :m14"); 172 | this.m14 = m14.floatValue(); 173 | Number m15 = (Number)map.get(Keyword.intern("m15")); 174 | if(m15 == null) 175 | throw new IllegalArgumentException("Map needs key :m15"); 176 | this.m15 = m15.floatValue(); 177 | } 178 | 179 | public Matrix(Object obj){ 180 | super(); 181 | if(obj instanceof Matrix){ 182 | Matrix m = (Matrix)obj; 183 | this.m0 = m.m0; 184 | this.m1 = m.m1; 185 | this.m2 = m.m2; 186 | this.m3 = m.m3; 187 | this.m4 = m.m4; 188 | this.m5 = m.m5; 189 | this.m6 = m.m6; 190 | this.m7 = m.m7; 191 | this.m8 = m.m8; 192 | this.m9 = m.m9; 193 | this.m10 = m.m10; 194 | this.m11 = m.m11; 195 | this.m12 = m.m12; 196 | this.m13 = m.m13; 197 | this.m14 = m.m14; 198 | this.m15 = m.m15; 199 | }else if(obj instanceof APersistentMap){ 200 | APersistentMap map = (APersistentMap)obj; 201 | Number m0 = (Number)map.get(Keyword.intern("m0")); 202 | if(m0 == null) 203 | throw new IllegalArgumentException("Map needs key :m0"); 204 | this.m0 = m0.floatValue(); 205 | Number m1 = (Number)map.get(Keyword.intern("m1")); 206 | if(m1 == null) 207 | throw new IllegalArgumentException("Map needs key :m1"); 208 | this.m1 = m1.floatValue(); 209 | Number m2 = (Number)map.get(Keyword.intern("m2")); 210 | if(m2 == null) 211 | throw new IllegalArgumentException("Map needs key :m2"); 212 | this.m2 = m2.floatValue(); 213 | Number m3 = (Number)map.get(Keyword.intern("m3")); 214 | if(m3 == null) 215 | throw new IllegalArgumentException("Map needs key :m3"); 216 | this.m3 = m3.floatValue(); 217 | Number m4 = (Number)map.get(Keyword.intern("m4")); 218 | if(m4 == null) 219 | throw new IllegalArgumentException("Map needs key :m4"); 220 | this.m4 = m4.floatValue(); 221 | Number m5 = (Number)map.get(Keyword.intern("m5")); 222 | if(m5 == null) 223 | throw new IllegalArgumentException("Map needs key :m5"); 224 | this.m5 = m5.floatValue(); 225 | Number m6 = (Number)map.get(Keyword.intern("m6")); 226 | if(m6 == null) 227 | throw new IllegalArgumentException("Map needs key :m6"); 228 | this.m6 = m6.floatValue(); 229 | Number m7 = (Number)map.get(Keyword.intern("m7")); 230 | if(m7 == null) 231 | throw new IllegalArgumentException("Map needs key :m7"); 232 | this.m7 = m7.floatValue(); 233 | Number m8 = (Number)map.get(Keyword.intern("m8")); 234 | if(m8 == null) 235 | throw new IllegalArgumentException("Map needs key :m8"); 236 | this.m8 = m8.floatValue(); 237 | Number m9 = (Number)map.get(Keyword.intern("m9")); 238 | if(m9 == null) 239 | throw new IllegalArgumentException("Map needs key :m9"); 240 | this.m9 = m9.floatValue(); 241 | Number m10 = (Number)map.get(Keyword.intern("m10")); 242 | if(m10 == null) 243 | throw new IllegalArgumentException("Map needs key :m10"); 244 | this.m10 = m10.floatValue(); 245 | Number m11 = (Number)map.get(Keyword.intern("m11")); 246 | if(m11 == null) 247 | throw new IllegalArgumentException("Map needs key :m11"); 248 | this.m11 = m11.floatValue(); 249 | Number m12 = (Number)map.get(Keyword.intern("m12")); 250 | if(m12 == null) 251 | throw new IllegalArgumentException("Map needs key :m12"); 252 | this.m12 = m12.floatValue(); 253 | Number m13 = (Number)map.get(Keyword.intern("m13")); 254 | if(m13 == null) 255 | throw new IllegalArgumentException("Map needs key :m13"); 256 | this.m13 = m13.floatValue(); 257 | Number m14 = (Number)map.get(Keyword.intern("m14")); 258 | if(m14 == null) 259 | throw new IllegalArgumentException("Map needs key :m14"); 260 | this.m14 = m14.floatValue(); 261 | Number m15 = (Number)map.get(Keyword.intern("m15")); 262 | if(m15 == null) 263 | throw new IllegalArgumentException("Map needs key :m15"); 264 | this.m15 = m15.floatValue(); 265 | } 266 | else if (obj instanceof APersistentVector) { 267 | APersistentVector vec = (APersistentVector)obj; 268 | if(vec.count() != 16) 269 | throw new IllegalArgumentException("PersistentVector needs to be of size 16"); 270 | this.m0 = ((Number)vec.get(0)).floatValue(); 271 | this.m4 = ((Number)vec.get(1)).floatValue(); 272 | this.m8 = ((Number)vec.get(2)).floatValue(); 273 | this.m12 = ((Number)vec.get(3)).floatValue(); 274 | this.m1 = ((Number)vec.get(4)).floatValue(); 275 | this.m5 = ((Number)vec.get(5)).floatValue(); 276 | this.m9 = ((Number)vec.get(6)).floatValue(); 277 | this.m13 = ((Number)vec.get(7)).floatValue(); 278 | this.m2 = ((Number)vec.get(8)).floatValue(); 279 | this.m6 = ((Number)vec.get(9)).floatValue(); 280 | this.m10 = ((Number)vec.get(10)).floatValue(); 281 | this.m14 = ((Number)vec.get(11)).floatValue(); 282 | this.m3 = ((Number)vec.get(12)).floatValue(); 283 | this.m7 = ((Number)vec.get(13)).floatValue(); 284 | this.m11 = ((Number)vec.get(14)).floatValue(); 285 | this.m15 = ((Number)vec.get(15)).floatValue(); 286 | }else{ 287 | throw new IllegalArgumentException("obj of unsupported type "+obj); 288 | } 289 | } 290 | 291 | public Matrix(){ 292 | super(); 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /java/raylib/jna/Mesh.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.ptr.FloatByReference; 6 | import com.sun.jna.ptr.ByteByReference; 7 | import com.sun.jna.ptr.ShortByReference; 8 | import com.sun.jna.ptr.IntByReference; 9 | import clojure.lang.APersistentMap; 10 | import clojure.lang.Keyword; 11 | 12 | @FieldOrder({"vertexCount","triangleCount","vertices","texcoords","texcoords2","normals","tangents","colors","indices", 13 | "animVertices","animNormals","boneIds","boneWeights","vaoId","vboId"}) 14 | public class Mesh extends Structure{ 15 | public static class ByReference extends Mesh implements Structure.ByReference{ 16 | public ByReference(int vertexCount, int triangleCount, FloatByReference vertices, FloatByReference texcoords, FloatByReference texcoords2, 17 | FloatByReference normals, FloatByReference tangents, ByteByReference colors, ShortByReference indices, 18 | FloatByReference animVertices, FloatByReference animNormals, IntByReference boneIds, FloatByReference boneWeights, 19 | int vaoId, IntByReference vboId){ 20 | super(vertexCount,triangleCount,vertices,texcoords,texcoords2,normals,tangents,colors,indices, 21 | animVertices,animNormals,boneIds,boneWeights,vaoId,vboId); 22 | } 23 | 24 | public ByReference(){ 25 | super(); 26 | } 27 | 28 | public ByReference(APersistentMap map){ 29 | super(map); 30 | } 31 | 32 | public ByReference(ByReference br){ 33 | super((Mesh)br); 34 | } 35 | public ByReference(ByValue br){ 36 | super((Mesh)br); 37 | } 38 | public ByReference(Object obj){ 39 | super(obj); 40 | } 41 | } 42 | 43 | public static class ByValue extends Mesh implements Structure.ByValue{ 44 | public ByValue(int vertexCount, int triangleCount, FloatByReference vertices, FloatByReference texcoords, FloatByReference texcoords2, 45 | FloatByReference normals, FloatByReference tangents, ByteByReference colors, ShortByReference indices, 46 | FloatByReference animVertices, FloatByReference animNormals, IntByReference boneIds, FloatByReference boneWeights, 47 | int vaoId, IntByReference vboId){ 48 | super(vertexCount,triangleCount,vertices,texcoords,texcoords2,normals,tangents,colors,indices, 49 | animVertices,animNormals,boneIds,boneWeights,vaoId,vboId); 50 | } 51 | 52 | public ByValue(){ 53 | super(); 54 | } 55 | 56 | public ByValue(APersistentMap map){ 57 | super(map); 58 | } 59 | 60 | public ByValue(ByReference br){ 61 | super((Mesh)br); 62 | } 63 | public ByValue(Object obj){ 64 | super(obj); 65 | } 66 | } 67 | 68 | 69 | public int vertexCount; 70 | public int triangleCount; 71 | public FloatByReference vertices; 72 | public FloatByReference texcoords; 73 | public FloatByReference texcoords2; 74 | public FloatByReference normals; 75 | public FloatByReference tangents; 76 | public ByteByReference colors; 77 | public ShortByReference indices; 78 | public FloatByReference animVertices; 79 | public FloatByReference animNormals; 80 | public IntByReference boneIds; 81 | public FloatByReference boneWeights; 82 | public int vaoId; 83 | public IntByReference vboId; 84 | 85 | public Mesh(int vertexCount, int triangleCount, FloatByReference vertices, FloatByReference texcoords, FloatByReference texcoords2, 86 | FloatByReference normals, FloatByReference tangents, ByteByReference colors, ShortByReference indices, 87 | FloatByReference animVertices, FloatByReference animNormals, IntByReference boneIds, FloatByReference boneWeights, 88 | int vaoId, IntByReference vboId){ 89 | super(); 90 | this.vertexCount = vertexCount; 91 | this.triangleCount = triangleCount; 92 | this.vertices = vertices; 93 | this.texcoords = texcoords; 94 | this.texcoords2 = texcoords2; 95 | this.normals = normals; 96 | this.tangents = tangents; 97 | this.colors = colors; 98 | this.indices = indices; 99 | this.animVertices = animVertices; 100 | this.animNormals = animNormals; 101 | this.boneIds = boneIds; 102 | this.boneWeights = boneWeights; 103 | this.vaoId = vaoId; 104 | this.vboId = vboId; 105 | } 106 | 107 | public Mesh(APersistentMap map){ 108 | super(); 109 | Number vertexCount = (Number)map.get(Keyword.intern("vertexCount")); 110 | if(vertexCount == null) 111 | throw new IllegalArgumentException("Map needs key :vertexCount"); 112 | this.vertexCount = vertexCount.intValue(); 113 | Number triangleCount = (Number)map.get(Keyword.intern("triangleCount")); 114 | if(triangleCount == null) 115 | throw new IllegalArgumentException("Map needs key :triangleCount"); 116 | this.triangleCount = triangleCount.intValue(); 117 | Object vertices = map.get(Keyword.intern("vertices")); 118 | if(vertices == null) 119 | throw new IllegalArgumentException("Map needs key :vertices"); 120 | this.vertices = (FloatByReference)vertices; 121 | Object texcoords = map.get(Keyword.intern("texcoords")); 122 | if(texcoords == null) 123 | throw new IllegalArgumentException("Map needs key :texcoords"); 124 | this.texcoords = (FloatByReference)texcoords; 125 | Object texcoords2 = map.get(Keyword.intern("texcoords2")); 126 | if(texcoords2 == null) 127 | throw new IllegalArgumentException("Map needs key :texcoords2"); 128 | this.texcoords2 = (FloatByReference)texcoords2; 129 | Object normals = map.get(Keyword.intern("normals")); 130 | if(normals == null) 131 | throw new IllegalArgumentException("Map needs key :normals"); 132 | this.normals = (FloatByReference)normals; 133 | Object tangents = map.get(Keyword.intern("tangents")); 134 | if(tangents == null) 135 | throw new IllegalArgumentException("Map needs key :tangents"); 136 | this.tangents = (FloatByReference)tangents; 137 | Object colors = map.get(Keyword.intern("colors")); 138 | if(colors == null) 139 | throw new IllegalArgumentException("Map needs key :colors"); 140 | this.colors = (ByteByReference)colors; 141 | Object indices = map.get(Keyword.intern("indices")); 142 | if(indices == null) 143 | throw new IllegalArgumentException("Map needs key :indices"); 144 | this.indices = (ShortByReference)indices; 145 | Object animVertices = map.get(Keyword.intern("animVertices")); 146 | if(animVertices == null) 147 | throw new IllegalArgumentException("Map needs key :animVertices"); 148 | this.animVertices = (FloatByReference)animVertices; 149 | Object animNormals = map.get(Keyword.intern("animNormals")); 150 | if(animNormals == null) 151 | throw new IllegalArgumentException("Map needs key :animNormals"); 152 | this.animNormals = (FloatByReference)animNormals; 153 | Object boneIds = map.get(Keyword.intern("boneIds")); 154 | if(boneIds == null) 155 | throw new IllegalArgumentException("Map needs key :boneIds"); 156 | this.boneIds = (IntByReference)boneIds; 157 | Object boneWeights = map.get(Keyword.intern("boneWeights")); 158 | if(boneWeights == null) 159 | throw new IllegalArgumentException("Map needs key :boneWeights"); 160 | this.boneWeights = (FloatByReference)boneWeights; 161 | Number vaoId = (Number)map.get(Keyword.intern("vaoId")); 162 | if(vaoId == null) 163 | throw new IllegalArgumentException("Map needs key :vaoId"); 164 | this.vaoId = vaoId.intValue(); 165 | Object vboId = map.get(Keyword.intern("vboId")); 166 | if(vboId == null) 167 | throw new IllegalArgumentException("Map needs key :vboId"); 168 | this.vboId = (IntByReference)vboId; 169 | } 170 | 171 | public Mesh(Mesh m){ 172 | super(); 173 | this.vertexCount = m.vertexCount; 174 | this.triangleCount = m.triangleCount; 175 | this.vertices = m.vertices; 176 | this.texcoords = m.texcoords; 177 | this.texcoords2 = m.texcoords2; 178 | this.normals = m.normals; 179 | this.tangents = m.tangents; 180 | this.colors = m.colors; 181 | this.indices = m.indices; 182 | this.animVertices = m.animVertices; 183 | this.animNormals = m.animNormals; 184 | this.boneIds = m.boneIds; 185 | this.boneWeights = m.boneWeights; 186 | this.vaoId = m.vaoId; 187 | this.vboId = m.vboId; 188 | } 189 | 190 | 191 | public Mesh(Object obj){ 192 | super(); 193 | if(obj instanceof Mesh){ 194 | Mesh m = (Mesh)obj; 195 | this.vertexCount = m.vertexCount; 196 | this.triangleCount = m.triangleCount; 197 | this.vertices = m.vertices; 198 | this.texcoords = m.texcoords; 199 | this.texcoords2 = m.texcoords2; 200 | this.normals = m.normals; 201 | this.tangents = m.tangents; 202 | this.colors = m.colors; 203 | this.indices = m.indices; 204 | this.animVertices = m.animVertices; 205 | this.animNormals = m.animNormals; 206 | this.boneIds = m.boneIds; 207 | this.boneWeights = m.boneWeights; 208 | this.vaoId = m.vaoId; 209 | this.vboId = m.vboId; 210 | }else if(obj instanceof APersistentMap){ 211 | APersistentMap map = (APersistentMap)obj; 212 | Number vertexCount = (Number)map.get(Keyword.intern("vertexCount")); 213 | if(vertexCount == null) 214 | throw new IllegalArgumentException("Map needs key :vertexCount"); 215 | this.vertexCount = vertexCount.intValue(); 216 | Number triangleCount = (Number)map.get(Keyword.intern("triangleCount")); 217 | if(triangleCount == null) 218 | throw new IllegalArgumentException("Map needs key :triangleCount"); 219 | this.triangleCount = triangleCount.intValue(); 220 | Object vertices = map.get(Keyword.intern("vertices")); 221 | if(vertices == null) 222 | throw new IllegalArgumentException("Map needs key :vertices"); 223 | this.vertices = (FloatByReference)vertices; 224 | Object texcoords = map.get(Keyword.intern("texcoords")); 225 | if(texcoords == null) 226 | throw new IllegalArgumentException("Map needs key :texcoords"); 227 | this.texcoords = (FloatByReference)texcoords; 228 | Object texcoords2 = map.get(Keyword.intern("texcoords2")); 229 | if(texcoords2 == null) 230 | throw new IllegalArgumentException("Map needs key :texcoords2"); 231 | this.texcoords2 = (FloatByReference)texcoords2; 232 | Object normals = map.get(Keyword.intern("normals")); 233 | if(normals == null) 234 | throw new IllegalArgumentException("Map needs key :normals"); 235 | this.normals = (FloatByReference)normals; 236 | Object tangents = map.get(Keyword.intern("tangents")); 237 | if(tangents == null) 238 | throw new IllegalArgumentException("Map needs key :tangents"); 239 | this.tangents = (FloatByReference)tangents; 240 | Object colors = map.get(Keyword.intern("colors")); 241 | if(colors == null) 242 | throw new IllegalArgumentException("Map needs key :colors"); 243 | this.colors = (ByteByReference)colors; 244 | Object indices = map.get(Keyword.intern("indices")); 245 | if(indices == null) 246 | throw new IllegalArgumentException("Map needs key :indices"); 247 | this.indices = (ShortByReference)indices; 248 | Object animVertices = map.get(Keyword.intern("animVertices")); 249 | if(animVertices == null) 250 | throw new IllegalArgumentException("Map needs key :animVertices"); 251 | this.animVertices = (FloatByReference)animVertices; 252 | Object animNormals = map.get(Keyword.intern("animNormals")); 253 | if(animNormals == null) 254 | throw new IllegalArgumentException("Map needs key :animNormals"); 255 | this.animNormals = (FloatByReference)animNormals; 256 | Object boneIds = map.get(Keyword.intern("boneIds")); 257 | if(boneIds == null) 258 | throw new IllegalArgumentException("Map needs key :boneIds"); 259 | this.boneIds = (IntByReference)boneIds; 260 | Object boneWeights = map.get(Keyword.intern("boneWeights")); 261 | if(boneWeights == null) 262 | throw new IllegalArgumentException("Map needs key :boneWeights"); 263 | this.boneWeights = (FloatByReference)boneWeights; 264 | Number vaoId = (Number)map.get(Keyword.intern("vaoId")); 265 | if(vaoId == null) 266 | throw new IllegalArgumentException("Map needs key :vaoId"); 267 | this.vaoId = vaoId.intValue(); 268 | Object vboId = map.get(Keyword.intern("vboId")); 269 | if(vboId == null) 270 | throw new IllegalArgumentException("Map needs key :vboId"); 271 | this.vboId = (IntByReference)vboId; 272 | }else{ 273 | throw new IllegalArgumentException("obj of unsupported type "+obj); 274 | } 275 | } 276 | 277 | public Mesh(){ 278 | super(); 279 | } 280 | } 281 | -------------------------------------------------------------------------------- /java/raylib/jna/Model.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.ptr.IntByReference; 6 | import raylib.jna.Matrix; 7 | import raylib.jna.Mesh; 8 | import raylib.jna.Material; 9 | import raylib.jna.BoneInfo; 10 | import clojure.lang.APersistentMap; 11 | import clojure.lang.APersistentVector; 12 | import clojure.lang.Keyword; 13 | 14 | @FieldOrder({"transform","meshCount","meshes","materialCount","materials","meshMaterial","boneCount","bones","bindPose"}) 15 | public class Model extends Structure{ 16 | public static class ByReference extends Model implements Structure.ByReference{ 17 | public ByReference(){ 18 | super(); 19 | } 20 | 21 | public ByReference(APersistentMap map){ 22 | super(map); 23 | } 24 | 25 | public ByReference(ByReference br){ 26 | super((Model)br); 27 | } 28 | public ByReference(ByValue br){ 29 | super((Model)br); 30 | } 31 | public ByReference(Object obj){ 32 | super(obj); 33 | } 34 | } 35 | public static class ByValue extends Model implements Structure.ByValue{ 36 | public ByValue(){ 37 | super(); 38 | } 39 | 40 | public ByValue(APersistentMap map){ 41 | super(map); 42 | } 43 | 44 | public ByValue(ByReference br){ 45 | super((Model)br); 46 | } 47 | public ByValue(Object obj){ 48 | super(obj); 49 | } 50 | } 51 | 52 | public Matrix transform; 53 | public int meshCount; 54 | public Mesh.ByReference meshes; 55 | public int materialCount; 56 | public Material.ByReference materials; 57 | public IntByReference meshMaterial; 58 | public int boneCount; 59 | public BoneInfo.ByReference bones; 60 | public Transform.ByReference bindPose; 61 | 62 | public Model(Matrix transform, int meshCount, Mesh.ByReference meshes, int materialCount, Material.ByReference materials, 63 | IntByReference meshMaterial, int boneCount, BoneInfo.ByReference bones, Transform.ByReference bindPose){ 64 | super(); 65 | this.transform = transform; 66 | this.meshCount = meshCount; 67 | this.meshes = meshes; 68 | this.materialCount = materialCount; 69 | this.materials = materials; 70 | this.meshMaterial = meshMaterial; 71 | this.boneCount = boneCount; 72 | this.bones = bones; 73 | this.bindPose = bindPose; 74 | } 75 | 76 | public Model(APersistentMap map){ 77 | super(); 78 | Object transform = map.get(Keyword.intern("transform")); 79 | if(transform == null) 80 | throw new IllegalArgumentException("Map needs key :transform"); 81 | if(transform instanceof APersistentMap){ 82 | this.transform = new Matrix((APersistentMap)transform); 83 | } 84 | else if(transform instanceof APersistentVector){ 85 | this.transform = new Matrix((APersistentVector)transform); 86 | } 87 | else if(transform instanceof Matrix){ 88 | this.transform = new Matrix((Matrix)transform); 89 | } 90 | else{ 91 | throw new IllegalArgumentException(":transform is of unsupported type"); 92 | } 93 | 94 | Number meshCount = (Number)map.get(Keyword.intern("meshCount")); 95 | if(meshCount == null) 96 | throw new IllegalArgumentException("Map needs key :meshCount"); 97 | this.meshCount = meshCount.intValue(); 98 | 99 | Object meshes = map.get(Keyword.intern("meshes")); 100 | if(meshes == null) 101 | throw new IllegalArgumentException("Map needs key :meshes"); 102 | if(meshes instanceof APersistentMap){ 103 | this.meshes = new Mesh.ByReference((APersistentMap)meshes); 104 | } 105 | else if(meshes instanceof Mesh.ByReference){ 106 | this.meshes = new Mesh.ByReference((Mesh.ByReference)meshes); 107 | } 108 | else{ 109 | throw new IllegalArgumentException(":meshes is of unsupported type"); 110 | } 111 | 112 | Number materialCount = (Number)map.get(Keyword.intern("materialCount")); 113 | if(materialCount == null) 114 | throw new IllegalArgumentException("Map needs key :materialCount"); 115 | this.materialCount = materialCount.intValue(); 116 | 117 | Object materials = map.get(Keyword.intern("materials")); 118 | if(materials == null) 119 | throw new IllegalArgumentException("Map needs key :materials"); 120 | if(materials instanceof APersistentMap){ 121 | this.materials = new Material.ByReference((APersistentMap)materials); 122 | } 123 | else if(materials instanceof Material.ByReference){ 124 | this.materials = new Material.ByReference((Material.ByReference)materials); 125 | } 126 | else{ 127 | throw new IllegalArgumentException(":materials is of unsupported type"); 128 | } 129 | 130 | Object meshMaterial = map.get(Keyword.intern("meshMaterial")); 131 | if(meshMaterial == null) 132 | throw new IllegalArgumentException("Map needs key :meshMaterial"); 133 | this.meshMaterial = (IntByReference)meshMaterial; 134 | 135 | Number boneCount = (Number)map.get(Keyword.intern("boneCount")); 136 | if(boneCount == null) 137 | throw new IllegalArgumentException("Map needs key :boneCount"); 138 | this.boneCount = boneCount.intValue(); 139 | 140 | Object bones = map.get(Keyword.intern("bones")); 141 | if(bones == null) 142 | throw new IllegalArgumentException("Map needs key :bones"); 143 | if(bones instanceof APersistentMap){ 144 | this.bones = new BoneInfo.ByReference((APersistentMap)bones); 145 | } 146 | else if(bones instanceof BoneInfo.ByReference){ 147 | this.bones = new BoneInfo.ByReference((BoneInfo.ByReference)bones); 148 | } 149 | else{ 150 | throw new IllegalArgumentException(":bones is of unsupported type"); 151 | } 152 | 153 | Object bindPose = map.get(Keyword.intern("bindPose")); 154 | if(bindPose == null) 155 | throw new IllegalArgumentException("Map needs key :bindPose"); 156 | if(bindPose instanceof APersistentMap){ 157 | this.bindPose = new Transform.ByReference((APersistentMap)bindPose); 158 | } 159 | else if(bindPose instanceof Transform.ByReference){ 160 | this.bindPose = new Transform.ByReference((Transform.ByReference)bindPose); 161 | } 162 | else{ 163 | throw new IllegalArgumentException(":bindPose is of unsupported type"); 164 | } 165 | } 166 | 167 | public Model(Model m){ 168 | super(); 169 | this.transform = new Matrix(transform); 170 | this.meshCount = meshCount; 171 | this.meshes = new Mesh.ByReference(meshes); 172 | this.materialCount = materialCount; 173 | this.materials = new Material.ByReference(materials); 174 | this.meshMaterial = meshMaterial; 175 | this.boneCount = boneCount; 176 | this.bones = new BoneInfo.ByReference(bones); 177 | this.bindPose = new Transform.ByReference(bindPose); 178 | } 179 | 180 | public Model(Object obj){ 181 | super(); 182 | if(obj instanceof Model){ 183 | Model m = (Model)obj; 184 | this.transform = new Matrix(transform); 185 | this.meshCount = meshCount; 186 | this.meshes = new Mesh.ByReference(meshes); 187 | this.materialCount = materialCount; 188 | this.materials = new Material.ByReference(materials); 189 | this.meshMaterial = meshMaterial; 190 | this.boneCount = boneCount; 191 | this.bones = new BoneInfo.ByReference(bones); 192 | this.bindPose = new Transform.ByReference(bindPose); 193 | }else if(obj instanceof APersistentMap){ 194 | APersistentMap map = (APersistentMap)obj; 195 | Object transform = map.get(Keyword.intern("transform")); 196 | if(transform == null) 197 | throw new IllegalArgumentException("Map needs key :transform"); 198 | if(transform instanceof APersistentMap){ 199 | this.transform = new Matrix((APersistentMap)transform); 200 | } 201 | else if(transform instanceof APersistentVector){ 202 | this.transform = new Matrix((APersistentVector)transform); 203 | } 204 | else if(transform instanceof Matrix){ 205 | this.transform = new Matrix((Matrix)transform); 206 | } 207 | else{ 208 | throw new IllegalArgumentException(":transform is of unsupported type"); 209 | } 210 | 211 | Number meshCount = (Number)map.get(Keyword.intern("meshCount")); 212 | if(meshCount == null) 213 | throw new IllegalArgumentException("Map needs key :meshCount"); 214 | this.meshCount = meshCount.intValue(); 215 | 216 | Object meshes = map.get(Keyword.intern("meshes")); 217 | if(meshes == null) 218 | throw new IllegalArgumentException("Map needs key :meshes"); 219 | if(meshes instanceof APersistentMap){ 220 | this.meshes = new Mesh.ByReference((APersistentMap)meshes); 221 | } 222 | else if(meshes instanceof Mesh.ByReference){ 223 | this.meshes = new Mesh.ByReference((Mesh.ByReference)meshes); 224 | } 225 | else{ 226 | throw new IllegalArgumentException(":meshes is of unsupported type"); 227 | } 228 | 229 | Number materialCount = (Number)map.get(Keyword.intern("materialCount")); 230 | if(materialCount == null) 231 | throw new IllegalArgumentException("Map needs key :materialCount"); 232 | this.materialCount = materialCount.intValue(); 233 | 234 | Object materials = map.get(Keyword.intern("materials")); 235 | if(materials == null) 236 | throw new IllegalArgumentException("Map needs key :materials"); 237 | if(materials instanceof APersistentMap){ 238 | this.materials = new Material.ByReference((APersistentMap)materials); 239 | } 240 | else if(materials instanceof Material.ByReference){ 241 | this.materials = new Material.ByReference((Material.ByReference)materials); 242 | } 243 | else{ 244 | throw new IllegalArgumentException(":materials is of unsupported type"); 245 | } 246 | 247 | Object meshMaterial = map.get(Keyword.intern("meshMaterial")); 248 | if(meshMaterial == null) 249 | throw new IllegalArgumentException("Map needs key :meshMaterial"); 250 | this.meshMaterial = (IntByReference)meshMaterial; 251 | 252 | Number boneCount = (Number)map.get(Keyword.intern("boneCount")); 253 | if(boneCount == null) 254 | throw new IllegalArgumentException("Map needs key :boneCount"); 255 | this.boneCount = boneCount.intValue(); 256 | 257 | Object bones = map.get(Keyword.intern("bones")); 258 | if(bones == null) 259 | throw new IllegalArgumentException("Map needs key :bones"); 260 | if(bones instanceof APersistentMap){ 261 | this.bones = new BoneInfo.ByReference((APersistentMap)bones); 262 | } 263 | else if(bones instanceof BoneInfo.ByReference){ 264 | this.bones = new BoneInfo.ByReference((BoneInfo.ByReference)bones); 265 | } 266 | else{ 267 | throw new IllegalArgumentException(":bones is of unsupported type"); 268 | } 269 | 270 | Object bindPose = map.get(Keyword.intern("bindPose")); 271 | if(bindPose == null) 272 | throw new IllegalArgumentException("Map needs key :bindPose"); 273 | if(bindPose instanceof APersistentMap){ 274 | this.bindPose = new Transform.ByReference((APersistentMap)bindPose); 275 | } 276 | else if(bindPose instanceof Transform.ByReference){ 277 | this.bindPose = new Transform.ByReference((Transform.ByReference)bindPose); 278 | } 279 | else{ 280 | throw new IllegalArgumentException(":bindPose is of unsupported type"); 281 | } 282 | }else{ 283 | throw new IllegalArgumentException("obj of unsupported type "+obj); 284 | } 285 | } 286 | 287 | public Model(){ 288 | super(); 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /java/raylib/jna/ModelAnimation.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Transform; 6 | import raylib.jna.BoneInfo; 7 | import clojure.lang.Keyword; 8 | import clojure.lang.APersistentMap; 9 | 10 | @FieldOrder({"boneCount","bones","frameCount","framePoses"}) 11 | public class ModelAnimation extends Structure{ 12 | public static class ByReference extends ModelAnimation implements Structure.ByReference{ 13 | public ByReference(){ 14 | super(); 15 | } 16 | 17 | public ByReference(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByReference(ByReference br){ 22 | super((ModelAnimation)br); 23 | } 24 | 25 | public ByReference(ByValue br){ 26 | super((ModelAnimation)br); 27 | } 28 | public ByReference(Object obj){ 29 | super(obj); 30 | } 31 | } 32 | public static class ByValue extends ModelAnimation implements Structure.ByValue{ 33 | public ByValue(){ 34 | super(); 35 | } 36 | 37 | public ByValue(APersistentMap map){ 38 | super(map); 39 | } 40 | 41 | public ByValue(ByReference br){ 42 | super((ModelAnimation)br); 43 | } 44 | public ByValue(Object obj){ 45 | super(obj); 46 | } 47 | } 48 | 49 | 50 | public int boneCount; 51 | public BoneInfo.ByReference bones; 52 | public int frameCount; 53 | public Transform.ByReference framePoses; 54 | //public Transform.ByReference[] framePoses; 55 | 56 | public ModelAnimation(int boneCount, BoneInfo.ByReference bones, int frameCount, Transform.ByReference framePoses){ 57 | //public ModelAnimation(int boneCount, BoneInfo.ByReference bones, int frameCount, Transform.ByReference[] framePoses){ 58 | super(); 59 | this.boneCount = boneCount; 60 | this.bones = bones; 61 | this.frameCount = frameCount; 62 | this.framePoses = framePoses; 63 | } 64 | 65 | public ModelAnimation(ModelAnimation m){ 66 | super(); 67 | this.boneCount = m.boneCount; 68 | this.bones = new BoneInfo.ByReference(m.bones); 69 | this.frameCount = m.frameCount; 70 | this.framePoses = new Transform.ByReference(m.framePoses); 71 | } 72 | 73 | public ModelAnimation(APersistentMap map){ 74 | super(); 75 | Number boneCount = (Number)map.get(Keyword.intern("boneCount")); 76 | if(boneCount == null) 77 | throw new IllegalArgumentException("Map needs key :boneCount"); 78 | this.boneCount = boneCount.intValue(); 79 | 80 | Object bones = map.get(Keyword.intern("bones")); 81 | if(bones == null) 82 | throw new IllegalArgumentException("Map needs key :bones"); 83 | if(bones instanceof APersistentMap){ 84 | this.bones = new BoneInfo.ByReference((APersistentMap)bones); 85 | } 86 | else if(bones instanceof BoneInfo.ByReference){ 87 | this.bones = new BoneInfo.ByReference((BoneInfo.ByReference)bones); 88 | } 89 | else{ 90 | throw new IllegalArgumentException(":bones is of unsupported type"); 91 | } 92 | 93 | Number frameCount = (Number)map.get(Keyword.intern("frameCount")); 94 | if(frameCount == null) 95 | throw new IllegalArgumentException("Map needs key :frameCount"); 96 | this.frameCount = frameCount.intValue(); 97 | 98 | Object framePoses = map.get(Keyword.intern("framePoses")); 99 | if(framePoses == null) 100 | throw new IllegalArgumentException("Map needs key :framePoses"); 101 | this.framePoses = (Transform.ByReference)framePoses; 102 | //this.framePoses = (Transform.ByReference[])framePoses; 103 | } 104 | 105 | public ModelAnimation(Object obj){ 106 | super(); 107 | if(obj instanceof ModelAnimation){ 108 | ModelAnimation m = (ModelAnimation)obj; 109 | this.boneCount = m.boneCount; 110 | this.bones = new BoneInfo.ByReference(m.bones); 111 | this.frameCount = m.frameCount; 112 | this.framePoses = new Transform.ByReference(m.framePoses); 113 | }else if(obj instanceof APersistentMap){ 114 | APersistentMap map = (APersistentMap)obj; 115 | Number boneCount = (Number)map.get(Keyword.intern("boneCount")); 116 | if(boneCount == null) 117 | throw new IllegalArgumentException("Map needs key :boneCount"); 118 | this.boneCount = boneCount.intValue(); 119 | 120 | Object bones = map.get(Keyword.intern("bones")); 121 | if(bones == null) 122 | throw new IllegalArgumentException("Map needs key :bones"); 123 | if(bones instanceof APersistentMap){ 124 | this.bones = new BoneInfo.ByReference((APersistentMap)bones); 125 | } 126 | else if(bones instanceof BoneInfo.ByReference){ 127 | this.bones = new BoneInfo.ByReference((BoneInfo.ByReference)bones); 128 | } 129 | else{ 130 | throw new IllegalArgumentException(":bones is of unsupported type"); 131 | } 132 | 133 | Number frameCount = (Number)map.get(Keyword.intern("frameCount")); 134 | if(frameCount == null) 135 | throw new IllegalArgumentException("Map needs key :frameCount"); 136 | this.frameCount = frameCount.intValue(); 137 | 138 | Object framePoses = map.get(Keyword.intern("framePoses")); 139 | if(framePoses == null) 140 | throw new IllegalArgumentException("Map needs key :framePoses"); 141 | this.framePoses = (Transform.ByReference)framePoses; 142 | }else{ 143 | throw new IllegalArgumentException("obj of unsupported type "+obj); 144 | } 145 | } 146 | 147 | public ModelAnimation(){ 148 | super(); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /java/raylib/jna/Music.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.Pointer; 6 | import raylib.jna.AudioStream; 7 | import clojure.lang.APersistentMap; 8 | import clojure.lang.Keyword; 9 | 10 | @FieldOrder({"ctxType","ctxData","sampleCount","loopCount","stream"}) 11 | public class Music extends Structure{ 12 | public static class ByValue extends Music implements Structure.ByValue{ 13 | public ByValue(){ 14 | super(); 15 | } 16 | 17 | public ByValue(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByValue(int ctxType, Pointer ctxData, int sampleCount, int loopCount, AudioStream stream){ 22 | super(ctxType,ctxData,sampleCount,loopCount,stream); 23 | } 24 | public ByValue(Object obj){ 25 | super(obj); 26 | } 27 | } 28 | 29 | public int ctxType; 30 | public Pointer ctxData; 31 | public int sampleCount; 32 | public int loopCount; 33 | public AudioStream stream; 34 | 35 | public Music(APersistentMap map){ 36 | super(); 37 | Number ctxType = (Number)map.get(Keyword.intern("ctxType")); 38 | if(ctxType == null) 39 | throw new IllegalArgumentException("Map needs key :ctxType"); 40 | this.ctxType = ctxType.intValue(); 41 | 42 | Object ctxData = map.get(Keyword.intern("ctxData")); 43 | if(ctxData == null) 44 | throw new IllegalArgumentException("Map needs key :ctxData"); 45 | this.ctxData = (Pointer)ctxData; 46 | 47 | Number sampleCount = (Number)map.get(Keyword.intern("sampleCount")); 48 | if(sampleCount == null) 49 | throw new IllegalArgumentException("Map needs key :sampleCount"); 50 | this.sampleCount = sampleCount.intValue(); 51 | 52 | Number loopCount = (Number)map.get(Keyword.intern("loopCount")); 53 | if(loopCount == null) 54 | throw new IllegalArgumentException("Map needs key :loopCount"); 55 | this.loopCount = loopCount.intValue(); 56 | 57 | Object stream = map.get(Keyword.intern("stream")); 58 | if(stream == null) 59 | throw new IllegalArgumentException("Map needs key :stream"); 60 | if(stream instanceof APersistentMap){ 61 | this.stream = new AudioStream((APersistentMap)stream); 62 | } 63 | else if(stream instanceof AudioStream){ 64 | this.stream = new AudioStream((AudioStream)stream); 65 | } 66 | else{ 67 | throw new IllegalArgumentException(":stream is of unsupported type"); 68 | } 69 | } 70 | 71 | public Music(int ctxType, Pointer ctxData, int sampleCount, int loopCount, AudioStream stream){ 72 | super(); 73 | this.ctxType = ctxType; 74 | this.ctxData = ctxData; 75 | this.sampleCount = sampleCount; 76 | this.loopCount = loopCount; 77 | this.stream = stream; 78 | } 79 | 80 | public Music(Music m){ 81 | super(); 82 | this.ctxType = m.ctxType; 83 | this.ctxData = m.ctxData; 84 | this.sampleCount = m.sampleCount; 85 | this.loopCount = m.loopCount; 86 | this.stream = new AudioStream(m.stream); 87 | } 88 | public Music(Object obj){ 89 | super(); 90 | if(obj instanceof Music){ 91 | Music m = (Music)obj; 92 | this.ctxType = m.ctxType; 93 | this.ctxData = m.ctxData; 94 | this.sampleCount = m.sampleCount; 95 | this.loopCount = m.loopCount; 96 | this.stream = new AudioStream(m.stream); 97 | }else if(obj instanceof APersistentMap){ 98 | APersistentMap map = (APersistentMap)obj; 99 | Number ctxType = (Number)map.get(Keyword.intern("ctxType")); 100 | if(ctxType == null) 101 | throw new IllegalArgumentException("Map needs key :ctxType"); 102 | this.ctxType = ctxType.intValue(); 103 | 104 | Object ctxData = map.get(Keyword.intern("ctxData")); 105 | if(ctxData == null) 106 | throw new IllegalArgumentException("Map needs key :ctxData"); 107 | this.ctxData = (Pointer)ctxData; 108 | 109 | Number sampleCount = (Number)map.get(Keyword.intern("sampleCount")); 110 | if(sampleCount == null) 111 | throw new IllegalArgumentException("Map needs key :sampleCount"); 112 | this.sampleCount = sampleCount.intValue(); 113 | 114 | Number loopCount = (Number)map.get(Keyword.intern("loopCount")); 115 | if(loopCount == null) 116 | throw new IllegalArgumentException("Map needs key :loopCount"); 117 | this.loopCount = loopCount.intValue(); 118 | 119 | Object stream = map.get(Keyword.intern("stream")); 120 | if(stream == null) 121 | throw new IllegalArgumentException("Map needs key :stream"); 122 | if(stream instanceof APersistentMap){ 123 | this.stream = new AudioStream((APersistentMap)stream); 124 | } 125 | else if(stream instanceof AudioStream){ 126 | this.stream = new AudioStream((AudioStream)stream); 127 | } 128 | else{ 129 | throw new IllegalArgumentException(":stream is of unsupported type"); 130 | } 131 | }else{ 132 | throw new IllegalArgumentException("obj of unsupported type "+obj); 133 | } 134 | } 135 | public Music(){ 136 | super(); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /java/raylib/jna/NPatchInfo.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Rectangle; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"sourceRec","left","top","right","bottom","type"}) 10 | public class NPatchInfo extends Structure{ 11 | public static class ByValue extends NPatchInfo implements Structure.ByValue{ 12 | public ByValue(){ 13 | super(); 14 | } 15 | 16 | public ByValue(APersistentMap map){ 17 | super(map); 18 | } 19 | 20 | public ByValue(Rectangle sourceRec, int left, int top, int right, int bottom, int type){ 21 | super(sourceRec, left, top, right, bottom, type); 22 | } 23 | public ByValue(Object obj){ 24 | super(obj); 25 | } 26 | } 27 | 28 | public Rectangle sourceRec; 29 | public int left; 30 | public int top; 31 | public int right; 32 | public int bottom; 33 | public int type; 34 | 35 | public NPatchInfo(Rectangle sourceRec, int left, int top, int right, int bottom, int type){ 36 | super(); 37 | this.sourceRec = sourceRec; 38 | this.left = left; 39 | this.top = top; 40 | this.right = right; 41 | this.bottom = bottom; 42 | this.type = type; 43 | } 44 | 45 | public NPatchInfo(APersistentMap map){ 46 | Object sourceRec = map.get(Keyword.intern("sourceRec")); 47 | if(sourceRec == null) 48 | throw new IllegalArgumentException("Map needs key :sourceRec"); 49 | if(sourceRec instanceof APersistentMap){ 50 | this.sourceRec = new Rectangle((APersistentMap)sourceRec); 51 | } 52 | else if(sourceRec instanceof Rectangle){ 53 | this.sourceRec = new Rectangle((Rectangle)sourceRec); 54 | } 55 | else{ 56 | throw new IllegalArgumentException(":sourceRec is of unsupported type"); 57 | } 58 | 59 | Number left = (Number)map.get(Keyword.intern("left")); 60 | if(left == null) 61 | throw new IllegalArgumentException("Map needs key :left"); 62 | this.left = left.intValue(); 63 | 64 | Number top = (Number)map.get(Keyword.intern("top")); 65 | if(top == null) 66 | throw new IllegalArgumentException("Map needs key :top"); 67 | this.top = top.intValue(); 68 | 69 | Number right = (Number)map.get(Keyword.intern("right")); 70 | if(right == null) 71 | throw new IllegalArgumentException("Map needs key :right"); 72 | this.right = right.intValue(); 73 | 74 | Number bottom = (Number)map.get(Keyword.intern("bottom")); 75 | if(bottom == null) 76 | throw new IllegalArgumentException("Map needs key :bottom"); 77 | this.bottom = bottom.intValue(); 78 | 79 | Number type = (Number)map.get(Keyword.intern("type")); 80 | if(type == null) 81 | throw new IllegalArgumentException("Map needs key :type"); 82 | this.type = type.intValue(); 83 | } 84 | 85 | public NPatchInfo(NPatchInfo n){ 86 | super(); 87 | this.sourceRec = new Rectangle(n.sourceRec); 88 | this.left = n.left; 89 | this.top = n.top; 90 | this.right = n.right; 91 | this.bottom = n.bottom; 92 | this.type = n.type; 93 | } 94 | 95 | public NPatchInfo(Object obj){ 96 | super(); 97 | if(obj instanceof NPatchInfo){ 98 | NPatchInfo n = (NPatchInfo)obj; 99 | this.sourceRec = new Rectangle(n.sourceRec); 100 | this.left = n.left; 101 | this.top = n.top; 102 | this.right = n.right; 103 | this.bottom = n.bottom; 104 | this.type = n.type; 105 | }else if(obj instanceof APersistentMap){ 106 | APersistentMap map = (APersistentMap)obj; 107 | Object sourceRec = map.get(Keyword.intern("sourceRec")); 108 | if(sourceRec == null) 109 | throw new IllegalArgumentException("Map needs key :sourceRec"); 110 | if(sourceRec instanceof APersistentMap){ 111 | this.sourceRec = new Rectangle((APersistentMap)sourceRec); 112 | } 113 | else if(sourceRec instanceof Rectangle){ 114 | this.sourceRec = new Rectangle((Rectangle)sourceRec); 115 | } 116 | else{ 117 | throw new IllegalArgumentException(":sourceRec is of unsupported type"); 118 | } 119 | 120 | Number left = (Number)map.get(Keyword.intern("left")); 121 | if(left == null) 122 | throw new IllegalArgumentException("Map needs key :left"); 123 | this.left = left.intValue(); 124 | 125 | Number top = (Number)map.get(Keyword.intern("top")); 126 | if(top == null) 127 | throw new IllegalArgumentException("Map needs key :top"); 128 | this.top = top.intValue(); 129 | 130 | Number right = (Number)map.get(Keyword.intern("right")); 131 | if(right == null) 132 | throw new IllegalArgumentException("Map needs key :right"); 133 | this.right = right.intValue(); 134 | 135 | Number bottom = (Number)map.get(Keyword.intern("bottom")); 136 | if(bottom == null) 137 | throw new IllegalArgumentException("Map needs key :bottom"); 138 | this.bottom = bottom.intValue(); 139 | 140 | Number type = (Number)map.get(Keyword.intern("type")); 141 | if(type == null) 142 | throw new IllegalArgumentException("Map needs key :type"); 143 | this.type = type.intValue(); 144 | }else{ 145 | throw new IllegalArgumentException("obj of unsupported type "+obj); 146 | } 147 | } 148 | 149 | public NPatchInfo(){ 150 | super(); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /java/raylib/jna/RAudioBuffer.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | 6 | @FieldOrder({"unused"}) 7 | public class RAudioBuffer extends Structure{ 8 | public static class ByReference extends RAudioBuffer implements Structure.ByReference{} 9 | public static class ByValue extends RAudioBuffer implements Structure.ByValue{} 10 | public int unused; 11 | } 12 | -------------------------------------------------------------------------------- /java/raylib/jna/Ray.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Vector3; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | import clojure.lang.APersistentVector; 9 | 10 | @FieldOrder({"position","direction"}) 11 | public class Ray extends Structure{ 12 | public static class ByValue extends Ray implements Structure.ByValue{ 13 | public ByValue(){ 14 | super(); 15 | } 16 | 17 | public ByValue(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByValue(Vector3 position, Vector3 direction){ 22 | super(position, direction); 23 | } 24 | public ByValue(Object obj){ 25 | super(obj); 26 | } 27 | } 28 | public Vector3 position; 29 | public Vector3 direction; 30 | 31 | public Ray(APersistentMap map){ 32 | super(); 33 | Object position = map.get(Keyword.intern("position")); 34 | if(position == null) 35 | throw new IllegalArgumentException("Map needs key :position"); 36 | if(position instanceof APersistentMap){ 37 | this.position = new Vector3((APersistentMap)position); 38 | } 39 | else if(position instanceof APersistentVector){ 40 | this.position = new Vector3((APersistentVector)position); 41 | } 42 | else if(position instanceof Vector3){ 43 | this.position = new Vector3((Vector3)position); 44 | } 45 | else{ 46 | throw new IllegalArgumentException(":position is of unsupported type"); 47 | } 48 | 49 | Object direction = map.get(Keyword.intern("direction")); 50 | if(direction == null) 51 | throw new IllegalArgumentException("Map needs key :direction"); 52 | if(direction instanceof APersistentMap){ 53 | this.direction = new Vector3((APersistentMap)direction); 54 | } 55 | else if(direction instanceof APersistentVector){ 56 | this.direction = new Vector3((APersistentVector)direction); 57 | } 58 | else if(direction instanceof Vector3){ 59 | this.direction = new Vector3((Vector3)direction); 60 | } 61 | else{ 62 | throw new IllegalArgumentException(":direction is of unsupported type"); 63 | } 64 | } 65 | 66 | public Ray(Vector3 position, Vector3 direction){ 67 | super(); 68 | this.position = position; 69 | this.direction = direction; 70 | } 71 | 72 | public Ray(Ray r){ 73 | super(); 74 | this.position = new Vector3(r.position); 75 | this.direction = new Vector3(r.direction); 76 | } 77 | 78 | public Ray(Object obj){ 79 | super(); 80 | if(obj instanceof Ray){ 81 | Ray r = (Ray)obj; 82 | this.position = new Vector3(r.position); 83 | this.direction = new Vector3(r.direction); 84 | }else if(obj instanceof APersistentMap){ 85 | APersistentMap map = (APersistentMap)obj; 86 | Object position = map.get(Keyword.intern("position")); 87 | if(position == null) 88 | throw new IllegalArgumentException("Map needs key :position"); 89 | if(position instanceof APersistentMap){ 90 | this.position = new Vector3((APersistentMap)position); 91 | } 92 | else if(position instanceof APersistentVector){ 93 | this.position = new Vector3((APersistentVector)position); 94 | } 95 | else if(position instanceof Vector3){ 96 | this.position = new Vector3((Vector3)position); 97 | } 98 | else{ 99 | throw new IllegalArgumentException(":position is of unsupported type"); 100 | } 101 | 102 | Object direction = map.get(Keyword.intern("direction")); 103 | if(direction == null) 104 | throw new IllegalArgumentException("Map needs key :direction"); 105 | if(direction instanceof APersistentMap){ 106 | this.direction = new Vector3((APersistentMap)direction); 107 | } 108 | else if(direction instanceof APersistentVector){ 109 | this.direction = new Vector3((APersistentVector)direction); 110 | } 111 | else if(direction instanceof Vector3){ 112 | this.direction = new Vector3((Vector3)direction); 113 | } 114 | else{ 115 | throw new IllegalArgumentException(":direction is of unsupported type"); 116 | } 117 | }else{ 118 | throw new IllegalArgumentException("obj of unsupported type "+obj); 119 | } 120 | } 121 | 122 | public Ray(){ 123 | super(); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /java/raylib/jna/RayHitInfo.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Vector3; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | import clojure.lang.APersistentVector; 9 | 10 | @FieldOrder({"hit","distance","position","normal"}) 11 | public class RayHitInfo extends Structure{ 12 | public static class ByValue extends RayHitInfo implements Structure.ByValue{ 13 | public ByValue(){ 14 | super(); 15 | } 16 | 17 | public ByValue(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByValue(boolean hit, float distance, Vector3 position, Vector3 normal){ 22 | super(hit,distance,position,normal); 23 | } 24 | 25 | public ByValue(Object obj){ 26 | super(obj); 27 | } 28 | } 29 | public boolean hit; 30 | public float distance; 31 | public Vector3 position; 32 | public Vector3 normal; 33 | 34 | public RayHitInfo(APersistentMap map){ 35 | super(); 36 | Object position = map.get(Keyword.intern("position")); 37 | if(position == null) 38 | throw new IllegalArgumentException("Map needs key :position"); 39 | if(position instanceof APersistentMap){ 40 | this.position = new Vector3((APersistentMap)position); 41 | } 42 | else if(position instanceof APersistentVector){ 43 | this.position = new Vector3((APersistentVector)position); 44 | } 45 | else if(position instanceof Vector3){ 46 | this.position = new Vector3((Vector3)position); 47 | } 48 | else{ 49 | throw new IllegalArgumentException(":position is of unsupported type"); 50 | } 51 | 52 | Object normal = map.get(Keyword.intern("normal")); 53 | if(normal == null) 54 | throw new IllegalArgumentException("Map needs key :normal"); 55 | if(normal instanceof APersistentMap){ 56 | this.normal = new Vector3((APersistentMap)normal); 57 | } 58 | else if(normal instanceof APersistentVector){ 59 | this.normal = new Vector3((APersistentVector)normal); 60 | } 61 | else if(normal instanceof Vector3){ 62 | this.normal = new Vector3((Vector3)normal); 63 | } 64 | else{ 65 | throw new IllegalArgumentException(":normal is of unsupported type"); 66 | } 67 | } 68 | 69 | public RayHitInfo(boolean hit, float distance, Vector3 position, Vector3 normal){ 70 | super(); 71 | this.hit = hit; 72 | this.distance = distance; 73 | this.position = position; 74 | this.normal = normal; 75 | } 76 | 77 | public RayHitInfo(RayHitInfo r){ 78 | super(); 79 | this.hit = r.hit; 80 | this.distance = r.distance; 81 | this.position = new Vector3(r.position); 82 | this.normal = new Vector3(r.normal); 83 | } 84 | 85 | public RayHitInfo(Object obj){ 86 | super(); 87 | if(obj instanceof RayHitInfo){ 88 | RayHitInfo r = (RayHitInfo)obj; 89 | this.hit = r.hit; 90 | this.distance = r.distance; 91 | this.position = new Vector3(r.position); 92 | this.normal = new Vector3(r.normal); 93 | }else if(obj instanceof APersistentMap){ 94 | APersistentMap map = (APersistentMap)obj; 95 | Object position = map.get(Keyword.intern("position")); 96 | if(position == null) 97 | throw new IllegalArgumentException("Map needs key :position"); 98 | if(position instanceof APersistentMap){ 99 | this.position = new Vector3((APersistentMap)position); 100 | } 101 | else if(position instanceof APersistentVector){ 102 | this.position = new Vector3((APersistentVector)position); 103 | } 104 | else if(position instanceof Vector3){ 105 | this.position = new Vector3((Vector3)position); 106 | } 107 | else{ 108 | throw new IllegalArgumentException(":position is of unsupported type"); 109 | } 110 | 111 | Object normal = map.get(Keyword.intern("normal")); 112 | if(normal == null) 113 | throw new IllegalArgumentException("Map needs key :normal"); 114 | if(normal instanceof APersistentMap){ 115 | this.normal = new Vector3((APersistentMap)normal); 116 | } 117 | else if(normal instanceof APersistentVector){ 118 | this.normal = new Vector3((APersistentVector)normal); 119 | } 120 | else if(normal instanceof Vector3){ 121 | this.normal = new Vector3((Vector3)normal); 122 | } 123 | else{ 124 | throw new IllegalArgumentException(":normal is of unsupported type"); 125 | } 126 | }else{ 127 | throw new IllegalArgumentException("obj of unsupported type "+obj); 128 | } 129 | } 130 | 131 | public RayHitInfo(){ 132 | super(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /java/raylib/jna/Rectangle.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentMap; 6 | import clojure.lang.Keyword; 7 | 8 | @FieldOrder({"x","y","width","height"}) 9 | public class Rectangle extends Structure{ 10 | public static class ByReference extends Rectangle implements Structure.ByReference { 11 | public ByReference(float x, float y, float width, float height){ 12 | super(x,y,width,height); 13 | } 14 | 15 | public ByReference(){ 16 | super(); 17 | } 18 | 19 | public ByReference(ByReference r){ 20 | super((Rectangle)r); 21 | } 22 | 23 | public ByReference(ByValue r){ 24 | super((Rectangle)r); 25 | } 26 | 27 | public ByReference(APersistentMap map){ 28 | super(map); 29 | } 30 | public ByReference(Object obj){ 31 | super(obj); 32 | } 33 | } 34 | public static class ByValue extends Rectangle implements Structure.ByValue { 35 | public ByValue(float x, float y, float width, float height){ 36 | super(x,y,width,height); 37 | } 38 | 39 | public ByValue(){ 40 | super(); 41 | } 42 | 43 | public ByValue(ByReference r){ 44 | super((Rectangle)r); 45 | } 46 | 47 | public ByValue(APersistentMap map){ 48 | super(map); 49 | } 50 | public ByValue(Object obj){ 51 | super(obj); 52 | } 53 | } 54 | 55 | public float x; 56 | public float y; 57 | public float width; 58 | public float height; 59 | 60 | public Rectangle(float x, float y, float width, float height){ 61 | super(); 62 | this.x = x; 63 | this.y = y; 64 | this.width = width; 65 | this.height = height; 66 | } 67 | 68 | public Rectangle(Rectangle r){ 69 | super(); 70 | this.x = r.x; 71 | this.y = r.y; 72 | this.width = r.width; 73 | this.height = r.height; 74 | } 75 | 76 | public Rectangle(APersistentMap map) throws IllegalArgumentException{ 77 | super(); 78 | Number x = (Number)map.get(Keyword.intern("x")); 79 | if(x == null) 80 | throw new IllegalArgumentException("Map needs key :x"); 81 | this.x = x.floatValue(); 82 | Number y = (Number)map.get(Keyword.intern("y")); 83 | if(y == null) 84 | throw new IllegalArgumentException("Map needs key :y"); 85 | this.y = y.floatValue(); 86 | Number width = (Number)map.get(Keyword.intern("width")); 87 | if(width == null) 88 | throw new IllegalArgumentException("Map needs key :width"); 89 | this.width = width.floatValue(); 90 | Number height = (Number)map.get(Keyword.intern("height")); 91 | if(height == null) 92 | throw new IllegalArgumentException("Map needs key :height"); 93 | this.height = height.floatValue(); 94 | } 95 | 96 | public Rectangle(Object obj){ 97 | super(); 98 | if(obj instanceof Rectangle){ 99 | Rectangle r = (Rectangle)obj; 100 | this.x = r.x; 101 | this.y = r.y; 102 | this.width = r.width; 103 | this.height = r.height; 104 | }else if(obj instanceof APersistentMap){ 105 | APersistentMap map = (APersistentMap)obj; 106 | Number x = (Number)map.get(Keyword.intern("x")); 107 | if(x == null) 108 | throw new IllegalArgumentException("Map needs key :x"); 109 | this.x = x.floatValue(); 110 | Number y = (Number)map.get(Keyword.intern("y")); 111 | if(y == null) 112 | throw new IllegalArgumentException("Map needs key :y"); 113 | this.y = y.floatValue(); 114 | Number width = (Number)map.get(Keyword.intern("width")); 115 | if(width == null) 116 | throw new IllegalArgumentException("Map needs key :width"); 117 | this.width = width.floatValue(); 118 | Number height = (Number)map.get(Keyword.intern("height")); 119 | if(height == null) 120 | throw new IllegalArgumentException("Map needs key :height"); 121 | this.height = height.floatValue(); 122 | }else{ 123 | throw new IllegalArgumentException("obj of unsupported type "+obj); 124 | } 125 | } 126 | 127 | public Rectangle(){ 128 | super(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /java/raylib/jna/RenderTexture2D.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentMap; 6 | import clojure.lang.Keyword; 7 | import raylib.jna.Texture2D; 8 | 9 | @FieldOrder({"id","texture","depth","depthTexture"}) 10 | public class RenderTexture2D extends Structure{ 11 | public static class ByValue extends RenderTexture2D implements Structure.ByValue { 12 | public ByValue(){ 13 | super(); 14 | } 15 | 16 | public ByValue(APersistentMap map){ 17 | super(map); 18 | } 19 | 20 | public ByValue(int id, Texture2D texture, Texture2D depth, boolean depthTexture){ 21 | super(id, texture, depth, depthTexture); 22 | } 23 | public ByValue(Object obj){ 24 | super(obj); 25 | } 26 | } 27 | 28 | public int id; 29 | public Texture2D texture; 30 | public Texture2D depth; 31 | public boolean depthTexture; 32 | 33 | public RenderTexture2D(APersistentMap map){ 34 | Number id = (Number)map.get(Keyword.intern("id")); 35 | if(id == null) 36 | throw new IllegalArgumentException("Map needs key :id"); 37 | this.id = id.intValue(); 38 | 39 | Object texture = map.get(Keyword.intern("texture")); 40 | if(texture == null) 41 | throw new IllegalArgumentException("Map needs key :texture"); 42 | if(texture instanceof APersistentMap){ 43 | this.texture = new Texture2D((APersistentMap)texture); 44 | } 45 | else if(texture instanceof Texture2D){ 46 | this.texture = new Texture2D((Texture2D)texture); 47 | } 48 | else{ 49 | throw new IllegalArgumentException(":texture is of unsupported type"); 50 | } 51 | 52 | Boolean depthTexture = (Boolean)map.get(Keyword.intern("depthTexture")); 53 | if(depthTexture == null) 54 | throw new IllegalArgumentException("Map needs key :depthTexture"); 55 | this.depthTexture = depthTexture.booleanValue(); 56 | } 57 | 58 | public RenderTexture2D(int id, Texture2D texture, Texture2D depth, boolean depthTexture){ 59 | super(); 60 | this.id = id; 61 | this.texture = texture; 62 | this.depth = depth; 63 | this.depthTexture = depthTexture; 64 | } 65 | 66 | public RenderTexture2D(RenderTexture2D r){ 67 | super(); 68 | this.id = r.id; 69 | this.texture = new Texture2D(r.texture); 70 | this.depth = new Texture2D(r.depth); 71 | this.depthTexture = r.depthTexture; 72 | } 73 | 74 | public RenderTexture2D(Object obj) throws IllegalArgumentException{ 75 | super(); 76 | if(obj instanceof RenderTexture2D){ 77 | RenderTexture2D r = (RenderTexture2D)obj; 78 | this.id = r.id; 79 | this.texture = new Texture2D(r.texture); 80 | this.depth = new Texture2D(r.depth); 81 | this.depthTexture = r.depthTexture; 82 | }else if(obj instanceof APersistentMap){ 83 | APersistentMap map = (APersistentMap)obj; 84 | Number id = (Number)map.get(Keyword.intern("id")); 85 | if(id == null) 86 | throw new IllegalArgumentException("Map needs key :id"); 87 | this.id = id.intValue(); 88 | 89 | Object texture = map.get(Keyword.intern("texture")); 90 | if(texture == null) 91 | throw new IllegalArgumentException("Map needs key :texture"); 92 | if(texture instanceof APersistentMap){ 93 | this.texture = new Texture2D((APersistentMap)texture); 94 | } 95 | else if(texture instanceof Texture2D){ 96 | this.texture = new Texture2D((Texture2D)texture); 97 | } 98 | else{ 99 | throw new IllegalArgumentException(":texture is of unsupported type"); 100 | } 101 | 102 | Boolean depthTexture = (Boolean)map.get(Keyword.intern("depthTexture")); 103 | if(depthTexture == null) 104 | throw new IllegalArgumentException("Map needs key :depthTexture"); 105 | this.depthTexture = depthTexture.booleanValue(); 106 | }else{ 107 | throw new IllegalArgumentException("obj of unsupported type "+obj); 108 | } 109 | } 110 | 111 | public RenderTexture2D(){ 112 | super(); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /java/raylib/jna/Shader.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.ptr.IntByReference; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"id","locs"}) 10 | public class Shader extends Structure{ 11 | public static class ByValue extends Shader implements Structure.ByValue { 12 | public ByValue(){ 13 | super(); 14 | } 15 | 16 | public ByValue(APersistentMap map){ 17 | super(map); 18 | } 19 | 20 | public ByValue(int id, IntByReference locs){ 21 | super(id, locs); 22 | } 23 | public ByValue(Object obj){ 24 | super(obj); 25 | } 26 | } 27 | 28 | public int id; 29 | public IntByReference locs; 30 | 31 | public Shader(APersistentMap map){ 32 | Number id = (Number)map.get(Keyword.intern("id")); 33 | if(id == null) 34 | throw new IllegalArgumentException("Map needs key :id"); 35 | this.id = id.intValue(); 36 | 37 | Object locs = map.get(Keyword.intern("locs")); 38 | if(locs == null) 39 | throw new IllegalArgumentException("Map needs key :locs"); 40 | this.locs = (IntByReference)locs; 41 | } 42 | 43 | public Shader(int id, IntByReference locs){ 44 | super(); 45 | this.id = id; 46 | this.locs = locs; 47 | } 48 | 49 | public Shader(Shader s){ 50 | super(); 51 | this.id = s.id; 52 | this.locs = s.locs; 53 | } 54 | 55 | public Shader(Object obj) throws IllegalArgumentException{ 56 | super(); 57 | if(obj instanceof Shader){ 58 | Shader s = (Shader)obj; 59 | this.id = s.id; 60 | this.locs = s.locs; 61 | }else if(obj instanceof APersistentMap){ 62 | APersistentMap map = (APersistentMap)obj; 63 | Number id = (Number)map.get(Keyword.intern("id")); 64 | if(id == null) 65 | throw new IllegalArgumentException("Map needs key :id"); 66 | this.id = id.intValue(); 67 | 68 | Object locs = map.get(Keyword.intern("locs")); 69 | if(locs == null) 70 | throw new IllegalArgumentException("Map needs key :locs"); 71 | this.locs = (IntByReference)locs; 72 | }else{ 73 | throw new IllegalArgumentException("obj of unsupported type "+obj); 74 | } 75 | } 76 | 77 | public Shader(){ 78 | super(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /java/raylib/jna/Sound.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.AudioStream; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"sampleCount","stream"}) 10 | public class Sound extends Structure{ 11 | public static class ByValue extends Sound implements Structure.ByValue{ 12 | public ByValue(){ 13 | super(); 14 | } 15 | 16 | public ByValue(APersistentMap map){ 17 | super(map); 18 | } 19 | 20 | public ByValue(int sampleCount, AudioStream stream){ 21 | super(sampleCount, stream); 22 | } 23 | public ByValue(Object obj){ 24 | super(obj); 25 | } 26 | } 27 | 28 | public int sampleCount; 29 | public AudioStream stream; 30 | 31 | public Sound(APersistentMap map){ 32 | super(); 33 | Number sampleCount = (Number)map.get(Keyword.intern("sampleCount")); 34 | if(sampleCount == null) 35 | throw new IllegalArgumentException("Map needs key :sampleCount"); 36 | this.sampleCount = sampleCount.intValue(); 37 | 38 | 39 | Object stream = map.get(Keyword.intern("stream")); 40 | if(stream == null) 41 | throw new IllegalArgumentException("Map needs key :stream"); 42 | if(stream instanceof APersistentMap){ 43 | this.stream = new AudioStream((APersistentMap)stream); 44 | } 45 | else if(stream instanceof AudioStream){ 46 | this.stream = new AudioStream((AudioStream)stream); 47 | } 48 | else{ 49 | throw new IllegalArgumentException(":stream is of unsupported type"); 50 | } 51 | } 52 | 53 | public Sound(int sampleCount, AudioStream stream){ 54 | super(); 55 | this.sampleCount = sampleCount; 56 | this.stream = stream; 57 | } 58 | 59 | public Sound(Sound s){ 60 | super(); 61 | this.sampleCount = s.sampleCount; 62 | this.stream = new AudioStream(s.stream); 63 | } 64 | 65 | public Sound(Object obj) throws IllegalArgumentException{ 66 | super(); 67 | if(obj instanceof Sound){ 68 | Sound s = (Sound)obj; 69 | this.sampleCount = s.sampleCount; 70 | this.stream = new AudioStream(s.stream); 71 | }else if(obj instanceof APersistentMap){ 72 | APersistentMap map = (APersistentMap)obj; 73 | Number sampleCount = (Number)map.get(Keyword.intern("sampleCount")); 74 | if(sampleCount == null) 75 | throw new IllegalArgumentException("Map needs key :sampleCount"); 76 | this.sampleCount = sampleCount.intValue(); 77 | 78 | 79 | Object stream = map.get(Keyword.intern("stream")); 80 | if(stream == null) 81 | throw new IllegalArgumentException("Map needs key :stream"); 82 | if(stream instanceof APersistentMap){ 83 | this.stream = new AudioStream((APersistentMap)stream); 84 | } 85 | else if(stream instanceof AudioStream){ 86 | this.stream = new AudioStream((AudioStream)stream); 87 | } 88 | else{ 89 | throw new IllegalArgumentException(":stream is of unsupported type"); 90 | } 91 | }else{ 92 | throw new IllegalArgumentException("obj of unsupported type "+obj); 93 | } 94 | } 95 | 96 | public Sound(){ 97 | super(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /java/raylib/jna/Texture2D.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentMap; 6 | import clojure.lang.Keyword; 7 | 8 | @FieldOrder({"id","width","height","mipmaps","format"}) 9 | public class Texture2D extends Structure{ 10 | public static class ByValue extends Texture2D implements Structure.ByValue { 11 | public ByValue(){ 12 | super(); 13 | } 14 | 15 | public ByValue(APersistentMap map){ 16 | super(map); 17 | } 18 | 19 | public ByValue(int id, int width, int height, int mipmaps, int format){ 20 | super(id, width, height, mipmaps, format); 21 | } 22 | public ByValue(Object obj){ 23 | super(obj); 24 | } 25 | public ByValue(ByReference obj){ 26 | super(obj); 27 | } 28 | } 29 | public static class ByReference extends Texture2D implements Structure.ByReference { 30 | public ByReference(){ 31 | super(); 32 | } 33 | 34 | public ByReference(APersistentMap map){ 35 | super(map); 36 | } 37 | 38 | public ByReference(int id, int width, int height, int mipmaps, int format){ 39 | super(id, width, height, mipmaps, format); 40 | } 41 | public ByReference(Object obj){ 42 | super(obj); 43 | } 44 | public ByReference(ByValue obj){ 45 | super(obj); 46 | } 47 | } 48 | public int id; 49 | public int width; 50 | public int height; 51 | public int mipmaps; 52 | public int format; 53 | 54 | public Texture2D(int id, int width, int height, int mipmaps, int format){ 55 | super(); 56 | this.id = id; 57 | this.width = width; 58 | this.height = height; 59 | this.mipmaps = mipmaps; 60 | this.format = format; 61 | } 62 | 63 | public Texture2D(Texture2D t){ 64 | super(); 65 | this.id = t.id; 66 | this.width = t.width; 67 | this.height = t.height; 68 | this.mipmaps = t.mipmaps; 69 | this.format = t.format; 70 | } 71 | 72 | public Texture2D(APersistentMap map) throws IllegalArgumentException{ 73 | super(); 74 | Number id = (Number)map.get(Keyword.intern("id")); 75 | if(id == null) 76 | throw new IllegalArgumentException("Map needs key :id"); 77 | this.id = id.intValue(); 78 | Number width = (Number)map.get(Keyword.intern("width")); 79 | if(width == null) 80 | throw new IllegalArgumentException("Map needs key :width"); 81 | this.width = width.intValue(); 82 | Number height = (Number)map.get(Keyword.intern("height")); 83 | if(height == null) 84 | throw new IllegalArgumentException("Map needs key :height"); 85 | this.height = height.intValue(); 86 | Number mipmaps = (Number)map.get(Keyword.intern("mipmaps")); 87 | if(mipmaps == null) 88 | throw new IllegalArgumentException("Map needs key :mipmaps"); 89 | this.mipmaps = mipmaps.intValue(); 90 | Number format = (Number)map.get(Keyword.intern("format")); 91 | if(format == null) 92 | throw new IllegalArgumentException("Map needs key :format"); 93 | this.format = format.intValue(); 94 | } 95 | 96 | public Texture2D(Object obj) throws IllegalArgumentException{ 97 | super(); 98 | if(obj instanceof Texture2D){ 99 | Texture2D t = (Texture2D)obj; 100 | this.id = t.id; 101 | this.width = t.width; 102 | this.height = t.height; 103 | this.mipmaps = t.mipmaps; 104 | this.format = t.format; 105 | }else if(obj instanceof APersistentMap){ 106 | APersistentMap map = (APersistentMap)obj; 107 | Number id = (Number)map.get(Keyword.intern("id")); 108 | if(id == null) 109 | throw new IllegalArgumentException("Map needs key :id"); 110 | this.id = id.intValue(); 111 | Number width = (Number)map.get(Keyword.intern("width")); 112 | if(width == null) 113 | throw new IllegalArgumentException("Map needs key :width"); 114 | this.width = width.intValue(); 115 | Number height = (Number)map.get(Keyword.intern("height")); 116 | if(height == null) 117 | throw new IllegalArgumentException("Map needs key :height"); 118 | this.height = height.intValue(); 119 | Number mipmaps = (Number)map.get(Keyword.intern("mipmaps")); 120 | if(mipmaps == null) 121 | throw new IllegalArgumentException("Map needs key :mipmaps"); 122 | this.mipmaps = mipmaps.intValue(); 123 | Number format = (Number)map.get(Keyword.intern("format")); 124 | if(format == null) 125 | throw new IllegalArgumentException("Map needs key :format"); 126 | this.format = format.intValue(); 127 | }else{ 128 | throw new IllegalArgumentException("obj of unsupported type "+obj); 129 | } 130 | } 131 | 132 | public Texture2D(){ 133 | super(); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /java/raylib/jna/Transform.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import raylib.jna.Vector3; 6 | import raylib.jna.Vector4; 7 | import clojure.lang.APersistentMap; 8 | import clojure.lang.APersistentVector; 9 | import clojure.lang.Keyword; 10 | 11 | @FieldOrder({"translation","rotation","scale"}) 12 | public class Transform extends Structure{ 13 | public static class ByReference extends Transform implements Structure.ByReference{ 14 | public ByReference(Vector3 translation, Vector4 rotation, Vector3 scale){ 15 | super(translation, rotation, scale); 16 | } 17 | 18 | public ByReference(){ 19 | super(); 20 | } 21 | 22 | public ByReference(ByReference br){ 23 | super((Transform)br); 24 | } 25 | public ByReference(ByValue br){ 26 | super((Transform)br); 27 | } 28 | 29 | public ByReference(APersistentMap map){ 30 | super(map); 31 | } 32 | public ByReference(Object obj){ 33 | super(obj); 34 | } 35 | } 36 | public static class ByValue extends Transform implements Structure.ByValue{ 37 | public ByValue(Vector3 translation, Vector4 rotation, Vector3 scale){ 38 | super(translation, rotation, scale); 39 | } 40 | 41 | public ByValue(){ 42 | super(); 43 | } 44 | 45 | public ByValue(ByReference br){ 46 | super((Transform)br); 47 | } 48 | 49 | public ByValue(APersistentMap map){ 50 | super(map); 51 | } 52 | public ByValue(Object obj){ 53 | super(obj); 54 | } 55 | } 56 | 57 | 58 | public Vector3 translation; 59 | public Vector4 rotation; 60 | public Vector3 scale; 61 | 62 | public Transform(Vector3 translation, Vector4 rotation, Vector3 scale){ 63 | super(); 64 | this.translation = translation; 65 | this.rotation = rotation; 66 | this.scale = scale; 67 | } 68 | 69 | public Transform(APersistentMap map){ 70 | super(); 71 | Object translation = map.get(Keyword.intern("translation")); 72 | if(translation == null) 73 | throw new IllegalArgumentException("Map needs key :translation"); 74 | if(translation instanceof APersistentMap){ 75 | this.translation = new Vector3((APersistentMap)translation); 76 | } 77 | else if(translation instanceof APersistentVector){ 78 | this.translation = new Vector3((APersistentVector)translation); 79 | } 80 | else if(translation instanceof Vector3){ 81 | this.translation = new Vector3((Vector3)translation); 82 | } 83 | else{ 84 | throw new IllegalArgumentException(":translation is of unsupported type"); 85 | } 86 | 87 | Object rotation = map.get(Keyword.intern("rotation")); 88 | if(rotation == null) 89 | throw new IllegalArgumentException("Map needs key :rotation"); 90 | if(rotation instanceof APersistentMap){ 91 | this.rotation = new Vector4((APersistentMap)rotation); 92 | } 93 | else if(rotation instanceof APersistentVector){ 94 | this.rotation = new Vector4((APersistentVector)rotation); 95 | } 96 | else if(rotation instanceof Vector4){ 97 | this.rotation = new Vector4((Vector4)rotation); 98 | } 99 | else{ 100 | throw new IllegalArgumentException(":rotation is of unsupported type"); 101 | } 102 | 103 | Object scale = map.get(Keyword.intern("scale")); 104 | if(scale == null) 105 | throw new IllegalArgumentException("Map needs key :scale"); 106 | if(scale instanceof APersistentMap){ 107 | this.scale = new Vector3((APersistentMap)scale); 108 | } 109 | else if(scale instanceof APersistentVector){ 110 | this.scale = new Vector3((APersistentVector)scale); 111 | } 112 | else if(scale instanceof Vector3){ 113 | this.scale = new Vector3((Vector3)scale); 114 | } 115 | else{ 116 | throw new IllegalArgumentException(":scale is of unsupported type"); 117 | } 118 | 119 | } 120 | 121 | public Transform(Transform t){ 122 | super(); 123 | this.translation = new Vector3(t.translation); 124 | this.rotation = new Vector4(t.rotation); 125 | this.scale = new Vector3(t.scale); 126 | } 127 | 128 | public Transform(Object obj) throws IllegalArgumentException{ 129 | super(); 130 | if(obj instanceof Transform){ 131 | Transform t = (Transform)obj; 132 | this.translation = new Vector3(t.translation); 133 | this.rotation = new Vector4(t.rotation); 134 | this.scale = new Vector3(t.scale); 135 | }else if(obj instanceof APersistentMap){ 136 | APersistentMap map = (APersistentMap)obj; 137 | Object translation = map.get(Keyword.intern("translation")); 138 | if(translation == null) 139 | throw new IllegalArgumentException("Map needs key :translation"); 140 | if(translation instanceof APersistentMap){ 141 | this.translation = new Vector3((APersistentMap)translation); 142 | } 143 | else if(translation instanceof APersistentVector){ 144 | this.translation = new Vector3((APersistentVector)translation); 145 | } 146 | else if(translation instanceof Vector3){ 147 | this.translation = new Vector3((Vector3)translation); 148 | } 149 | else{ 150 | throw new IllegalArgumentException(":translation is of unsupported type"); 151 | } 152 | 153 | Object rotation = map.get(Keyword.intern("rotation")); 154 | if(rotation == null) 155 | throw new IllegalArgumentException("Map needs key :rotation"); 156 | if(rotation instanceof APersistentMap){ 157 | this.rotation = new Vector4((APersistentMap)rotation); 158 | } 159 | else if(rotation instanceof APersistentVector){ 160 | this.rotation = new Vector4((APersistentVector)rotation); 161 | } 162 | else if(rotation instanceof Vector4){ 163 | this.rotation = new Vector4((Vector4)rotation); 164 | } 165 | else{ 166 | throw new IllegalArgumentException(":rotation is of unsupported type"); 167 | } 168 | 169 | Object scale = map.get(Keyword.intern("scale")); 170 | if(scale == null) 171 | throw new IllegalArgumentException("Map needs key :scale"); 172 | if(scale instanceof APersistentMap){ 173 | this.scale = new Vector3((APersistentMap)scale); 174 | } 175 | else if(scale instanceof APersistentVector){ 176 | this.scale = new Vector3((APersistentVector)scale); 177 | } 178 | else if(scale instanceof Vector3){ 179 | this.scale = new Vector3((Vector3)scale); 180 | } 181 | else{ 182 | throw new IllegalArgumentException(":scale is of unsupported type"); 183 | } 184 | }else{ 185 | throw new IllegalArgumentException("obj of unsupported type "+obj); 186 | } 187 | } 188 | 189 | public Transform(){ 190 | super(); 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /java/raylib/jna/Vector2.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentVector; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"x","y"}) 10 | public class Vector2 extends Structure{ 11 | public static class ByReference extends Vector2 implements Structure.ByReference{ 12 | public ByReference(float x, float y){ 13 | super(x,y); 14 | } 15 | 16 | public ByReference(){ 17 | super(); 18 | } 19 | 20 | public ByReference(APersistentVector vec){ 21 | super(vec); 22 | } 23 | 24 | public ByReference(APersistentMap map){ 25 | super(map); 26 | } 27 | 28 | public ByReference(Object obj){ 29 | super(obj); 30 | } 31 | } 32 | 33 | public static class ByValue extends Vector2 implements Structure.ByValue{ 34 | public ByValue(float x, float y){ 35 | super(x,y); 36 | } 37 | 38 | public ByValue(){ 39 | super(); 40 | } 41 | 42 | public ByValue(APersistentVector vec){ 43 | super(vec); 44 | } 45 | 46 | public ByValue(APersistentMap map){ 47 | super(map); 48 | } 49 | 50 | public ByValue(Object obj){ 51 | super(obj); 52 | } 53 | } 54 | 55 | public float x; 56 | public float y; 57 | 58 | public Vector2(float x, float y){ 59 | super(); 60 | this.x = x; 61 | this.y = y; 62 | } 63 | 64 | public Vector2(Vector2 v){ 65 | super(); 66 | this.x = v.x; 67 | this.y = v.y; 68 | } 69 | 70 | public Vector2(APersistentVector vec) throws IllegalArgumentException{ 71 | super(); 72 | if(vec.count() != 2) 73 | throw new IllegalArgumentException("Vector needs to be of size 2"); 74 | this.x = ((Number)vec.get(0)).floatValue(); 75 | this.y = ((Number)vec.get(1)).floatValue(); 76 | } 77 | 78 | public Vector2(APersistentMap map) throws IllegalArgumentException{ 79 | super(); 80 | Number x = (Number)map.get(Keyword.intern("x")); 81 | if(x == null) 82 | throw new IllegalArgumentException("Map needs key :x"); 83 | this.x = x.floatValue(); 84 | Number y = (Number)map.get(Keyword.intern("y")); 85 | if(y == null) 86 | throw new IllegalArgumentException("Map needs key :y"); 87 | this.y = y.floatValue(); 88 | } 89 | 90 | public Vector2(Object obj) throws IllegalArgumentException{ 91 | super(); 92 | if(obj instanceof Vector2){ 93 | Vector2 v = (Vector2)obj; 94 | this.x = v.x; 95 | this.y = v.y; 96 | }else if(obj instanceof APersistentVector){ 97 | APersistentVector vec = (APersistentVector)obj; 98 | if(vec.count() != 2) 99 | throw new IllegalArgumentException("Vector needs to be of size 2"); 100 | this.x = ((Number)vec.get(0)).floatValue(); 101 | this.y = ((Number)vec.get(1)).floatValue(); 102 | }else if(obj instanceof APersistentMap){ 103 | APersistentMap map = (APersistentMap)obj; 104 | Number x = (Number)map.get(Keyword.intern("x")); 105 | if(x == null) 106 | throw new IllegalArgumentException("Map needs key :x"); 107 | this.x = x.floatValue(); 108 | Number y = (Number)map.get(Keyword.intern("y")); 109 | if(y == null) 110 | throw new IllegalArgumentException("Map needs key :y"); 111 | this.y = y.floatValue(); 112 | }else{ 113 | throw new IllegalArgumentException("obj of unsupported type "+obj); 114 | } 115 | 116 | } 117 | 118 | public Vector2(){ 119 | super(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /java/raylib/jna/Vector3.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentVector; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"x","y","z"}) 10 | public class Vector3 extends Structure{ 11 | public static class ByReference extends Vector3 implements Structure.ByReference{ 12 | public ByReference(float x, float y, float z){ 13 | super(x,y,z); 14 | } 15 | 16 | public ByReference(){ 17 | super(); 18 | } 19 | 20 | public ByReference(APersistentVector vec){ 21 | super(vec); 22 | } 23 | 24 | public ByReference(APersistentMap map){ 25 | super(map); 26 | } 27 | 28 | public ByReference(Object obj){ 29 | super(obj); 30 | } 31 | } 32 | 33 | public static class ByValue extends Vector3 implements Structure.ByValue{ 34 | public ByValue(float x, float y, float z){ 35 | super(x,y,z); 36 | } 37 | 38 | public ByValue(){ 39 | super(); 40 | } 41 | 42 | public ByValue(APersistentVector vec){ 43 | super(vec); 44 | } 45 | 46 | public ByValue(APersistentMap map){ 47 | super(map); 48 | } 49 | 50 | public ByValue(Object obj){ 51 | super(obj); 52 | } 53 | } 54 | 55 | public float x; 56 | public float y; 57 | public float z; 58 | 59 | public Vector3(float x, float y, float z){ 60 | super(); 61 | this.x = x; 62 | this.y = y; 63 | this.z = z; 64 | } 65 | 66 | public Vector3(Vector3 v){ 67 | super(); 68 | this.x = v.x; 69 | this.y = v.y; 70 | this.z = v.z; 71 | } 72 | 73 | public Vector3(APersistentVector vec) throws IllegalArgumentException{ 74 | super(); 75 | if(vec.count() != 3) 76 | throw new IllegalArgumentException("PersistentVector needs to be of size 3"); 77 | this.x = ((Number)vec.nth(0)).floatValue(); 78 | this.y = ((Number)vec.nth(1)).floatValue(); 79 | this.z = ((Number)vec.nth(2)).floatValue(); 80 | } 81 | 82 | public Vector3(APersistentMap map) throws IllegalArgumentException{ 83 | super(); 84 | Number x = (Number)map.get(Keyword.intern("x")); 85 | if(x == null) 86 | throw new IllegalArgumentException("Map needs key :x"); 87 | this.x = x.floatValue(); 88 | Number y = (Number)map.get(Keyword.intern("y")); 89 | if(y == null) 90 | throw new IllegalArgumentException("Map needs key :y"); 91 | this.y = y.floatValue(); 92 | Number z = (Number)map.get(Keyword.intern("z")); 93 | if(z == null) 94 | throw new IllegalArgumentException("Map needs key :z"); 95 | this.z = z.floatValue(); 96 | } 97 | 98 | public Vector3(Object obj){ 99 | super(); 100 | if(obj instanceof Vector3){ 101 | Vector3 v = (Vector3)obj; 102 | this.x = v.x; 103 | this.y = v.y; 104 | this.z = v.z; 105 | }else if(obj instanceof APersistentVector){ 106 | APersistentVector vec = (APersistentVector)obj; 107 | if(vec.count() != 3) 108 | throw new IllegalArgumentException("PersistentVector needs to be of size 3"); 109 | this.x = ((Number)vec.nth(0)).floatValue(); 110 | this.y = ((Number)vec.nth(1)).floatValue(); 111 | this.z = ((Number)vec.nth(2)).floatValue(); 112 | }else if(obj instanceof APersistentMap){ 113 | APersistentMap map = (APersistentMap)obj; 114 | Number x = (Number)map.get(Keyword.intern("x")); 115 | if(x == null) 116 | throw new IllegalArgumentException("Map needs key :x"); 117 | this.x = x.floatValue(); 118 | Number y = (Number)map.get(Keyword.intern("y")); 119 | if(y == null) 120 | throw new IllegalArgumentException("Map needs key :y"); 121 | this.y = y.floatValue(); 122 | Number z = (Number)map.get(Keyword.intern("z")); 123 | if(z == null) 124 | throw new IllegalArgumentException("Map needs key :z"); 125 | this.z = z.floatValue(); 126 | }else{ 127 | throw new IllegalArgumentException("obj of unsupported type "+obj); 128 | } 129 | } 130 | 131 | public Vector3(){ 132 | super(); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /java/raylib/jna/Vector4.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentVector; 6 | import clojure.lang.APersistentMap; 7 | import clojure.lang.Keyword; 8 | 9 | @FieldOrder({"x","y","z","w"}) 10 | public class Vector4 extends Structure{ 11 | public static class ByReference extends Vector4 implements Structure.ByReference{ 12 | public ByReference(float x, float y, float z, float w){ 13 | super(x,y,z,w); 14 | } 15 | 16 | public ByReference(){ 17 | super(); 18 | } 19 | 20 | public ByReference(APersistentVector vec){ 21 | super(vec); 22 | } 23 | 24 | public ByReference(Object obj){ 25 | super(obj); 26 | } 27 | } 28 | 29 | public static class ByValue extends Vector4 implements Structure.ByValue{ 30 | public ByValue(float x, float y, float z, float w){ 31 | super(x,y,z,w); 32 | } 33 | 34 | public ByValue(){ 35 | super(); 36 | } 37 | 38 | public ByValue(APersistentVector vec){ 39 | super(vec); 40 | } 41 | 42 | public ByValue(Object obj){ 43 | super(obj); 44 | } 45 | } 46 | 47 | public float x; 48 | public float y; 49 | public float z; 50 | public float w; 51 | 52 | public Vector4(float x, float y, float z, float w){ 53 | super(); 54 | this.x = x; 55 | this.y = y; 56 | this.z = z; 57 | this.w = w; 58 | } 59 | 60 | public Vector4(Vector4 v){ 61 | super(); 62 | this.x = v.x; 63 | this.y = v.y; 64 | this.z = v.z; 65 | this.w = v.w; 66 | } 67 | 68 | public Vector4(APersistentVector vec) throws IllegalArgumentException{ 69 | super(); 70 | if(vec.count() != 4) 71 | throw new IllegalArgumentException("PersistentVector needs to be of size 4"); 72 | this.x = ((Number)vec.nth(0)).floatValue(); 73 | this.y = ((Number)vec.nth(1)).floatValue(); 74 | this.z = ((Number)vec.nth(2)).floatValue(); 75 | this.w = ((Number)vec.nth(3)).floatValue(); 76 | } 77 | 78 | public Vector4(APersistentMap map) throws IllegalArgumentException{ 79 | super(); 80 | Number x = (Number)map.get(Keyword.intern("x")); 81 | if(x == null) 82 | throw new IllegalArgumentException("Map needs key :x"); 83 | this.x = x.floatValue(); 84 | Number y = (Number)map.get(Keyword.intern("y")); 85 | if(y == null) 86 | throw new IllegalArgumentException("Map needs key :y"); 87 | this.y = y.floatValue(); 88 | Number z = (Number)map.get(Keyword.intern("z")); 89 | if(z == null) 90 | throw new IllegalArgumentException("Map needs key :z"); 91 | this.z = z.floatValue(); 92 | Number w = (Number)map.get(Keyword.intern("w")); 93 | if(w == null) 94 | throw new IllegalArgumentException("Map needs key :w"); 95 | this.w = w.floatValue(); 96 | } 97 | 98 | public Vector4(Object obj){ 99 | super(); 100 | if(obj instanceof Vector4){ 101 | Vector4 v = (Vector4)obj; 102 | this.x = v.x; 103 | this.y = v.y; 104 | this.z = v.z; 105 | this.w = v.w; 106 | }else if(obj instanceof APersistentVector){ 107 | APersistentVector vec = (APersistentVector)obj; 108 | if(vec.count() != 4) 109 | throw new IllegalArgumentException("PersistentVector needs to be of size 4"); 110 | this.x = ((Number)vec.nth(0)).floatValue(); 111 | this.y = ((Number)vec.nth(1)).floatValue(); 112 | this.z = ((Number)vec.nth(2)).floatValue(); 113 | this.w = ((Number)vec.nth(3)).floatValue(); 114 | }else if(obj instanceof APersistentMap){ 115 | APersistentMap map = (APersistentMap)obj; 116 | 117 | Number x = (Number)map.get(Keyword.intern("x")); 118 | if(x == null) 119 | throw new IllegalArgumentException("Map needs key :x"); 120 | this.x = x.floatValue(); 121 | Number y = (Number)map.get(Keyword.intern("y")); 122 | if(y == null) 123 | throw new IllegalArgumentException("Map needs key :y"); 124 | this.y = y.floatValue(); 125 | Number z = (Number)map.get(Keyword.intern("z")); 126 | if(z == null) 127 | throw new IllegalArgumentException("Map needs key :z"); 128 | this.z = z.floatValue(); 129 | Number w = (Number)map.get(Keyword.intern("w")); 130 | if(w == null) 131 | throw new IllegalArgumentException("Map needs key :w"); 132 | this.w = w.floatValue(); 133 | }else{ 134 | throw new IllegalArgumentException("obj of unsupported type "+obj); 135 | } 136 | } 137 | 138 | public Vector4(){ 139 | super(); 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /java/raylib/jna/VrDeviceInfo.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import clojure.lang.APersistentMap; 6 | import clojure.lang.Keyword; 7 | 8 | @FieldOrder({"hResolution","vResolution","hScreenSize","vScreenSize","vScreenCenter","eyeToScreenDistance","lensSeparationDistance", 9 | "interpupillaryDistance","lensDistortionValues","chromaAbCorrection"}) 10 | public class VrDeviceInfo extends Structure{ 11 | public static class ByValue extends VrDeviceInfo implements Structure.ByValue{ 12 | 13 | public ByValue(){ 14 | super(); 15 | } 16 | 17 | public ByValue(APersistentMap map){ 18 | super(map); 19 | } 20 | 21 | public ByValue(int hResolution, int vResolution, float hScreenSize, float vScreenSize, float vScreenCenter, float eyeToScreenDistance, 22 | float lensSeparationDistance, float interpupillaryDistance, float[] lensDistortionValues, float[] chromaAbCorrection){ 23 | super(hResolution, vResolution, hScreenSize, vScreenSize, vScreenCenter, eyeToScreenDistance,lensSeparationDistance,interpupillaryDistance, lensDistortionValues, chromaAbCorrection); 24 | } 25 | public ByValue(Object obj){ 26 | super(obj); 27 | } 28 | } 29 | 30 | public int hResolution; 31 | public int vResolution; 32 | public float hScreenSize; 33 | public float vScreenSize; 34 | public float vScreenCenter; 35 | public float eyeToScreenDistance; 36 | public float lensSeparationDistance; 37 | public float interpupillaryDistance; 38 | public float[] lensDistortionValues = new float[4]; 39 | public float[] chromaAbCorrection = new float[4]; 40 | 41 | public VrDeviceInfo(APersistentMap map) throws IllegalArgumentException{ 42 | super(); 43 | Number hResolution = (Number)map.get(Keyword.intern("hResolution")); 44 | if(hResolution == null) 45 | throw new IllegalArgumentException("Map needs key :hResolution"); 46 | this.hResolution = hResolution.intValue(); 47 | Number vResolution = (Number)map.get(Keyword.intern("vResolution")); 48 | if(vResolution == null) 49 | throw new IllegalArgumentException("Map needs key :vResolution"); 50 | this.vResolution = vResolution.intValue(); 51 | Number hScreenSize = (Number)map.get(Keyword.intern("hScreenSize")); 52 | if(hScreenSize == null) 53 | throw new IllegalArgumentException("Map needs key :hScreenSize"); 54 | this.hScreenSize = hScreenSize.floatValue(); 55 | Number vScreenSize = (Number)map.get(Keyword.intern("vScreenSize")); 56 | if(vScreenSize == null) 57 | throw new IllegalArgumentException("Map needs key :vScreenSize"); 58 | this.vScreenSize = vScreenSize.floatValue(); 59 | Number vScreenCenter = (Number)map.get(Keyword.intern("vScreenCenter")); 60 | if(vScreenCenter == null) 61 | throw new IllegalArgumentException("Map needs key :vScreenCenter"); 62 | this.vScreenCenter = vScreenCenter.floatValue(); 63 | Number eyeToScreenDistance = (Number)map.get(Keyword.intern("eyeToScreenDistance")); 64 | if(eyeToScreenDistance == null) 65 | throw new IllegalArgumentException("Map needs key :eyeToScreenDistance"); 66 | this.eyeToScreenDistance = eyeToScreenDistance.floatValue(); 67 | Number lensSeparationDistance = (Number)map.get(Keyword.intern("lensSeparationDistance")); 68 | if(lensSeparationDistance == null) 69 | throw new IllegalArgumentException("Map needs key :lensSeparationDistance"); 70 | this.lensSeparationDistance = lensSeparationDistance.floatValue(); 71 | Number interpupillaryDistance = (Number)map.get(Keyword.intern("interpupillaryDistance")); 72 | if(interpupillaryDistance == null) 73 | throw new IllegalArgumentException("Map needs key :interpupillaryDistance"); 74 | this.interpupillaryDistance = interpupillaryDistance.floatValue(); 75 | 76 | 77 | Object lensDistortionValues = map.get(Keyword.intern("lensDistortionValues")); 78 | if(lensDistortionValues == null) 79 | throw new IllegalArgumentException("Map needs key :lensDistortionValues"); 80 | this.lensDistortionValues = (float[])lensDistortionValues; 81 | Object chromaAbCorrection = map.get(Keyword.intern("chromaAbCorrection")); 82 | if(chromaAbCorrection == null) 83 | throw new IllegalArgumentException("Map needs key :chromaAbCorrection"); 84 | this.chromaAbCorrection = (float[])chromaAbCorrection; 85 | } 86 | 87 | 88 | public VrDeviceInfo(int hResolution, int vResolution, float hScreenSize, float vScreenSize, float vScreenCenter, float eyeToScreenDistance, 89 | float lensSeparationDistance, float interpupillaryDistance, float[] lensDistortionValues, float[] chromaAbCorrection){ 90 | super(); 91 | this.hResolution = hResolution; 92 | this.vResolution = vResolution; 93 | this.hScreenSize = hScreenSize; 94 | this.vScreenSize = vScreenSize; 95 | this.vScreenCenter = vScreenCenter; 96 | this.eyeToScreenDistance = eyeToScreenDistance; 97 | this.lensSeparationDistance = lensSeparationDistance; 98 | this.interpupillaryDistance = interpupillaryDistance; 99 | this.lensDistortionValues = lensDistortionValues; 100 | this.chromaAbCorrection = chromaAbCorrection; 101 | } 102 | 103 | public VrDeviceInfo(VrDeviceInfo v){ 104 | super(); 105 | this.hResolution = v.hResolution; 106 | this.vResolution = v.vResolution; 107 | this.hScreenSize = v.hScreenSize; 108 | this.vScreenSize = v.vScreenSize; 109 | this.vScreenCenter = v.vScreenCenter; 110 | this.eyeToScreenDistance = v.eyeToScreenDistance; 111 | this.lensSeparationDistance = v.lensSeparationDistance; 112 | this.interpupillaryDistance = v.interpupillaryDistance; 113 | this.lensDistortionValues = v.lensDistortionValues; 114 | this.chromaAbCorrection = v.chromaAbCorrection; 115 | } 116 | 117 | public VrDeviceInfo(Object obj) throws IllegalArgumentException{ 118 | super(); 119 | if(obj instanceof VrDeviceInfo){ 120 | VrDeviceInfo v = (VrDeviceInfo)obj; 121 | this.hResolution = v.hResolution; 122 | this.vResolution = v.vResolution; 123 | this.hScreenSize = v.hScreenSize; 124 | this.vScreenSize = v.vScreenSize; 125 | this.vScreenCenter = v.vScreenCenter; 126 | this.eyeToScreenDistance = v.eyeToScreenDistance; 127 | this.lensSeparationDistance = v.lensSeparationDistance; 128 | this.interpupillaryDistance = v.interpupillaryDistance; 129 | this.lensDistortionValues = v.lensDistortionValues; 130 | this.chromaAbCorrection = v.chromaAbCorrection; 131 | }else if(obj instanceof APersistentMap){ 132 | APersistentMap map = (APersistentMap)obj; 133 | Number hResolution = (Number)map.get(Keyword.intern("hResolution")); 134 | if(hResolution == null) 135 | throw new IllegalArgumentException("Map needs key :hResolution"); 136 | this.hResolution = hResolution.intValue(); 137 | Number vResolution = (Number)map.get(Keyword.intern("vResolution")); 138 | if(vResolution == null) 139 | throw new IllegalArgumentException("Map needs key :vResolution"); 140 | this.vResolution = vResolution.intValue(); 141 | Number hScreenSize = (Number)map.get(Keyword.intern("hScreenSize")); 142 | if(hScreenSize == null) 143 | throw new IllegalArgumentException("Map needs key :hScreenSize"); 144 | this.hScreenSize = hScreenSize.floatValue(); 145 | Number vScreenSize = (Number)map.get(Keyword.intern("vScreenSize")); 146 | if(vScreenSize == null) 147 | throw new IllegalArgumentException("Map needs key :vScreenSize"); 148 | this.vScreenSize = vScreenSize.floatValue(); 149 | Number vScreenCenter = (Number)map.get(Keyword.intern("vScreenCenter")); 150 | if(vScreenCenter == null) 151 | throw new IllegalArgumentException("Map needs key :vScreenCenter"); 152 | this.vScreenCenter = vScreenCenter.floatValue(); 153 | Number eyeToScreenDistance = (Number)map.get(Keyword.intern("eyeToScreenDistance")); 154 | if(eyeToScreenDistance == null) 155 | throw new IllegalArgumentException("Map needs key :eyeToScreenDistance"); 156 | this.eyeToScreenDistance = eyeToScreenDistance.floatValue(); 157 | Number lensSeparationDistance = (Number)map.get(Keyword.intern("lensSeparationDistance")); 158 | if(lensSeparationDistance == null) 159 | throw new IllegalArgumentException("Map needs key :lensSeparationDistance"); 160 | this.lensSeparationDistance = lensSeparationDistance.floatValue(); 161 | Number interpupillaryDistance = (Number)map.get(Keyword.intern("interpupillaryDistance")); 162 | if(interpupillaryDistance == null) 163 | throw new IllegalArgumentException("Map needs key :interpupillaryDistance"); 164 | this.interpupillaryDistance = interpupillaryDistance.floatValue(); 165 | 166 | 167 | Object lensDistortionValues = map.get(Keyword.intern("lensDistortionValues")); 168 | if(lensDistortionValues == null) 169 | throw new IllegalArgumentException("Map needs key :lensDistortionValues"); 170 | this.lensDistortionValues = (float[])lensDistortionValues; 171 | Object chromaAbCorrection = map.get(Keyword.intern("chromaAbCorrection")); 172 | if(chromaAbCorrection == null) 173 | throw new IllegalArgumentException("Map needs key :chromaAbCorrection"); 174 | this.chromaAbCorrection = (float[])chromaAbCorrection; 175 | }else{ 176 | throw new IllegalArgumentException("obj of unsupported type "+obj); 177 | } 178 | } 179 | 180 | public VrDeviceInfo(){ 181 | super(); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /java/raylib/jna/Wave.java: -------------------------------------------------------------------------------- 1 | package raylib.jna; 2 | 3 | import com.sun.jna.Structure; 4 | import com.sun.jna.Structure.FieldOrder; 5 | import com.sun.jna.Pointer; 6 | import clojure.lang.Keyword; 7 | import clojure.lang.APersistentMap; 8 | 9 | @FieldOrder({"sampleCount","sampleRate","sampleSize","channels","data"}) 10 | public class Wave extends Structure{ 11 | public static class ByReference extends Wave implements Structure.ByReference{ 12 | public ByReference(){ 13 | super(); 14 | } 15 | 16 | public ByReference(APersistentMap map){ 17 | super(map); 18 | } 19 | 20 | public ByReference(ByReference br){ 21 | super((Wave)br); 22 | } 23 | public ByReference(ByValue br){ 24 | super((Wave)br); 25 | } 26 | public ByReference(Object obj){ 27 | super(obj); 28 | } 29 | } 30 | 31 | public static class ByValue extends Wave implements Structure.ByValue{ 32 | public ByValue(){ 33 | super(); 34 | } 35 | 36 | public ByValue(APersistentMap map){ 37 | super(map); 38 | } 39 | 40 | public ByValue(ByReference br){ 41 | super((Wave)br); 42 | } 43 | public ByValue(Object obj){ 44 | super(obj); 45 | } 46 | } 47 | 48 | 49 | public int sampleCount; 50 | public int sampleRate; 51 | public int sampleSize; 52 | public int channels; 53 | public Pointer data; 54 | 55 | public Wave(APersistentMap map){ 56 | super(); 57 | Number sampleCount = (Number)map.get(Keyword.intern("sampleCount")); 58 | if(sampleCount == null) 59 | throw new IllegalArgumentException("Map needs key :sampleCount"); 60 | this.sampleCount = sampleCount.intValue(); 61 | Number sampleRate = (Number)map.get(Keyword.intern("sampleRate")); 62 | if(sampleRate == null) 63 | throw new IllegalArgumentException("Map needs key :sampleRate"); 64 | this.sampleRate = sampleRate.intValue(); 65 | Number sampleSize = (Number)map.get(Keyword.intern("sampleSize")); 66 | if(sampleSize == null) 67 | throw new IllegalArgumentException("Map needs key :sampleSize"); 68 | this.sampleSize = sampleSize.intValue(); 69 | Number channels = (Number)map.get(Keyword.intern("channels")); 70 | if(channels == null) 71 | throw new IllegalArgumentException("Map needs key :channels"); 72 | this.channels = channels.intValue(); 73 | Object data = map.get(Keyword.intern("data")); 74 | if(data == null) 75 | throw new IllegalArgumentException("Map needs key :data"); 76 | this.data = (Pointer)data; 77 | } 78 | 79 | public Wave(int sampleCount, int sampleRate, int sampleSize, int channels, Pointer data){ 80 | super(); 81 | this.sampleCount = sampleCount; 82 | this.sampleRate = sampleRate; 83 | this.sampleSize = sampleSize; 84 | this.channels = channels; 85 | this.data = data; 86 | } 87 | 88 | public Wave(Wave w){ 89 | super(); 90 | this.sampleCount = w.sampleCount; 91 | this.sampleRate = w.sampleRate; 92 | this.sampleSize = w.sampleSize; 93 | this.channels = w.channels; 94 | this.data = w.data; 95 | } 96 | 97 | public Wave(Object obj) throws IllegalArgumentException{ 98 | super(); 99 | if(obj instanceof Wave){ 100 | Wave w = (Wave)obj; 101 | this.sampleCount = w.sampleCount; 102 | this.sampleRate = w.sampleRate; 103 | this.sampleSize = w.sampleSize; 104 | this.channels = w.channels; 105 | this.data = w.data; 106 | }else if(obj instanceof APersistentMap){ 107 | APersistentMap map = (APersistentMap)obj; 108 | Number sampleCount = (Number)map.get(Keyword.intern("sampleCount")); 109 | if(sampleCount == null) 110 | throw new IllegalArgumentException("Map needs key :sampleCount"); 111 | this.sampleCount = sampleCount.intValue(); 112 | Number sampleRate = (Number)map.get(Keyword.intern("sampleRate")); 113 | if(sampleRate == null) 114 | throw new IllegalArgumentException("Map needs key :sampleRate"); 115 | this.sampleRate = sampleRate.intValue(); 116 | Number sampleSize = (Number)map.get(Keyword.intern("sampleSize")); 117 | if(sampleSize == null) 118 | throw new IllegalArgumentException("Map needs key :sampleSize"); 119 | this.sampleSize = sampleSize.intValue(); 120 | Number channels = (Number)map.get(Keyword.intern("channels")); 121 | if(channels == null) 122 | throw new IllegalArgumentException("Map needs key :channels"); 123 | this.channels = channels.intValue(); 124 | Object data = map.get(Keyword.intern("data")); 125 | if(data == null) 126 | throw new IllegalArgumentException("Map needs key :data"); 127 | this.data = (Pointer)data; 128 | }else{ 129 | throw new IllegalArgumentException("obj of unsupported type "+obj); 130 | } 131 | } 132 | 133 | public Wave(){ 134 | super(); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject clj-raylib "0.0.2" 2 | :description "raylib in clojure" 3 | :url "http://www.github.com/lsevero/clj-raylib" 4 | :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" 5 | :url "https://www.eclipse.org/legal/epl-2.0/"} 6 | :dependencies [[org.clojure/clojure "1.10.1"] 7 | [net.java.dev.jna/jna "5.5.0"]] 8 | :min-lein-version "2.8.0" 9 | :java-source-paths ["java"] 10 | :profiles {:dev {:plugins [[cider/cider-nrepl "0.22.3"]] 11 | :source-paths ["src" "test" "examples"]}} 12 | :source-paths ["src"] 13 | :repl-options {:init-ns clj-raylib.core 14 | :port 17020 15 | }) 16 | -------------------------------------------------------------------------------- /src/darwin/libraylib.3.0.0.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsevero/clj-raylib/e7e521aa68ca7037557855ae22b0b3be27ada0ff/src/darwin/libraylib.3.0.0.dylib -------------------------------------------------------------------------------- /src/linux-x86-64/libraylib.so.3.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsevero/clj-raylib/e7e521aa68ca7037557855ae22b0b3be27ada0ff/src/linux-x86-64/libraylib.so.3.0.0 -------------------------------------------------------------------------------- /src/linux-x86/libraylib.so.3.0.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsevero/clj-raylib/e7e521aa68ca7037557855ae22b0b3be27ada0ff/src/linux-x86/libraylib.so.3.0.0 -------------------------------------------------------------------------------- /src/win32-x86-64/libraylib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsevero/clj-raylib/e7e521aa68ca7037557855ae22b0b3be27ada0ff/src/win32-x86-64/libraylib.dll -------------------------------------------------------------------------------- /src/win32-x86/libraylib.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lsevero/clj-raylib/e7e521aa68ca7037557855ae22b0b3be27ada0ff/src/win32-x86/libraylib.dll -------------------------------------------------------------------------------- /test/clj_raylib/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns clj-raylib.core-test 2 | (:require [clojure.test :refer :all] 3 | [clj-raylib.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | --------------------------------------------------------------------------------