| Previous | 199869 Revisions | Next |
| r23953 Wednesday 26th June, 2013 at 10:08:09 UTC by Miodrag Milanović |
|---|
| (MickoWIP) made test compile (nw) |
| [/branches/micko/src/lib/librocket/Include] | |
| [/branches/micko/src/tools] | RocketInput.cpp* RocketInput.h* Shell.cpp* Shell.h* ShellFileInterface.cpp* ShellFileInterface.h* ShellOpenGL.h* ShellRenderInterfaceOpenGL.cpp* ShellRenderInterfaceOpenGL.h* ShellSystemInterface.cpp* ShellSystemInterface.h* main.cpp* tools.mak |
| [/branches/micko/src/tools/win32] | InputWin32.cpp* InputWin32.h* ShellWin32.cpp* |
| [/branches/micko/test] | Delicious-Bold.otf* Delicious-BoldItalic.otf* Delicious-Italic.otf* Delicious-Roman.otf* demo.rml* invader.rcss* invader.tga* rkt.rcss* window.rml* |
| r0 | r23953 | |
|---|---|---|
| 1 | <rml> | |
| 2 | <head> | |
| 3 | <title>MAME</title> | |
| 4 | <link type="text/template" href="window.rml" /> | |
| 5 | <style> | |
| 6 | body | |
| 7 | { | |
| 8 | width: 400px; | |
| 9 | height: 525px; | |
| 10 | ||
| 11 | margin: auto; | |
| 12 | } | |
| 13 | ||
| 14 | div#title_bar div#icon | |
| 15 | { | |
| 16 | icon-image-s: 332px 383px; | |
| 17 | icon-image-t: 191px 231px; | |
| 18 | } | |
| 19 | ||
| 20 | button | |
| 21 | { | |
| 22 | width: 350px; | |
| 23 | } | |
| 24 | </style> | |
| 25 | </head> | |
| 26 | <body template="window"> | |
| 27 | <button>Input (general)</button><br /> | |
| 28 | <button>Input (this game)</button><br /> | |
| 29 | <button>Bookkeeping Info</button><br /> | |
| 30 | <button>Game Information</button><br /> | |
| 31 | <button>Bios Selection</button><br /> | |
| 32 | <button>Slot Devices</button><br /> | |
| 33 | <button>Slider Controls</button><br /> | |
| 34 | <button>Video Options</button><br /> | |
| 35 | <button>Cheat</button><br /> | |
| 36 | <button>Select New Game</button><br /> | |
| 37 | <button onclick="exit">Exit</button> | |
| 38 | </body> | |
| 39 | </rml> |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | <template name="window" content="content"> | |
| 2 | <head> | |
| 3 | <link type="text/rcss" href="rkt.rcss"/> | |
| 4 | <link type="text/rcss" href="invader.rcss"/> | |
| 5 | </head> | |
| 6 | <body class="window"> | |
| 7 | <div id="title_bar"> | |
| 8 | <handle move_target="#document"> | |
| 9 | <div id="icon"></div> | |
| 10 | <span id="title">MAME Main Menu</span> | |
| 11 | </handle> | |
| 12 | </div> | |
| 13 | <div id="window"> | |
| 14 | <div id="content"> | |
| 15 | </div> | |
| 16 | </div> | |
| 17 | <handle size_target="#document" style="position: absolute; width: 16px; height: 16px; bottom: 0px; right: 0px;"></handle> | |
| 18 | </body> | |
| 19 | </template> |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| Added: svn:mime-type + application/octet-stream |
| r0 | r23953 | |
|---|---|---|
| 1 | body | |
| 2 | { | |
| 3 | font-family: Delicious; | |
| 4 | font-weight: normal; | |
| 5 | font-style: normal; | |
| 6 | font-size: 15; | |
| 7 | color: white; | |
| 8 | } | |
| 9 | ||
| 10 | body.window | |
| 11 | { | |
| 12 | padding-top: 43px; | |
| 13 | padding-bottom: 20px; | |
| 14 | ||
| 15 | min-width: 250px; | |
| 16 | max-width: 800px; | |
| 17 | ||
| 18 | min-height: 135px; | |
| 19 | max-height: 700px; | |
| 20 | } | |
| 21 | ||
| 22 | ||
| 23 | ||
| 24 | div#title_bar | |
| 25 | { | |
| 26 | z-index: 1; | |
| 27 | ||
| 28 | position: absolute; | |
| 29 | top: 0px; | |
| 30 | left: 0px; | |
| 31 | ||
| 32 | text-align: left; | |
| 33 | } | |
| 34 | ||
| 35 | div#title_bar div#icon | |
| 36 | { | |
| 37 | position: absolute; | |
| 38 | left: 20px; | |
| 39 | top: 2px; | |
| 40 | ||
| 41 | width: 51px; | |
| 42 | height: 39px; | |
| 43 | ||
| 44 | icon-decorator: image; | |
| 45 | icon-image-src: invader.tga; | |
| 46 | } | |
| 47 | ||
| 48 | div#title_bar span | |
| 49 | { | |
| 50 | padding-left: 85px; | |
| 51 | padding-right: 25px; | |
| 52 | padding-top: 17px; | |
| 53 | padding-bottom: 48px; | |
| 54 | ||
| 55 | font-size: 22; | |
| 56 | font-weight: bold; | |
| 57 | ||
| 58 | outline-font-effect: outline; | |
| 59 | outline-width: 1px; | |
| 60 | outline-color: black; | |
| 61 | ||
| 62 | background-decorator: tiled-horizontal; | |
| 63 | background-left-image: invader.tga 147px 0px 229px 85px; | |
| 64 | background-center-image: invader.tga stretch 229px 0px 230px 85px; | |
| 65 | background-right-image: invader.tga 231px 0px 246px 85px; | |
| 66 | } | |
| 67 | ||
| 68 | ||
| 69 | ||
| 70 | div#window | |
| 71 | { | |
| 72 | width: auto; | |
| 73 | padding: 10px 15px; | |
| 74 | ||
| 75 | background-decorator: tiled-box; | |
| 76 | background-top-left-image: invader.tga 0px 0px 133px 140px; | |
| 77 | background-top-right-image: invader.tga 136px 0px 146px 140px; | |
| 78 | background-top-image: invader.tga stretch 134px 0px 135px 140px; | |
| 79 | background-bottom-left-image: invader.tga 0px 140px 11px 151px; | |
| 80 | background-bottom-right-image: invader.tga 136px 140px 146px 151px; | |
| 81 | background-bottom-image: invader.tga stretch 11px 140px 12px 151px; | |
| 82 | background-left-image: invader.tga stretch 0px 139px 10px 140px; | |
| 83 | background-center-image: invader.tga stretch 11px 139px 12px 140px; | |
| 84 | } | |
| 85 | ||
| 86 | div#content | |
| 87 | { | |
| 88 | z-index: 2; | |
| 89 | ||
| 90 | width: auto; | |
| 91 | height: 100%; | |
| 92 | ||
| 93 | overflow: hidden auto; | |
| 94 | ||
| 95 | text-align: center; | |
| 96 | } | |
| 97 | ||
| 98 | ||
| 99 | ||
| 100 | p | |
| 101 | { | |
| 102 | text-align: left; | |
| 103 | margin-bottom: 1em; | |
| 104 | } | |
| 105 | ||
| 106 | h1 | |
| 107 | { | |
| 108 | margin-left: 0.4em; | |
| 109 | margin-bottom: 0.4em; | |
| 110 | ||
| 111 | text-align: left; | |
| 112 | font-size: 16; | |
| 113 | font-weight: bold; | |
| 114 | ||
| 115 | shadow-font-effect: shadow; | |
| 116 | shadow-offset: 1px 1px; | |
| 117 | shadow-color: black; | |
| 118 | } | |
| 119 | ||
| 120 | ||
| 121 | ||
| 122 | input, | |
| 123 | select, | |
| 124 | dataselect | |
| 125 | { | |
| 126 | margin-left: 20px; | |
| 127 | } | |
| 128 | ||
| 129 | input.submit | |
| 130 | { | |
| 131 | margin-left: 0px; | |
| 132 | } | |
| 133 | ||
| 134 | ||
| 135 | ||
| 136 | button, | |
| 137 | input.submit | |
| 138 | { | |
| 139 | display: inline-block; | |
| 140 | ||
| 141 | width: 159px; | |
| 142 | height: 37px; | |
| 143 | ||
| 144 | padding-top: 8px; | |
| 145 | vertical-align: -18px; | |
| 146 | ||
| 147 | font-size: 18; | |
| 148 | text-align: center; | |
| 149 | tab-index: auto; | |
| 150 | ||
| 151 | background-decorator: image; | |
| 152 | background-image: invader.tga 247px 0px 406px 45px; | |
| 153 | } | |
| 154 | ||
| 155 | button:focus, | |
| 156 | input.submit:focus | |
| 157 | { | |
| 158 | font-weight: bold; | |
| 159 | ||
| 160 | shadow-font-effect: shadow; | |
| 161 | shadow-offset: 1px 1px; | |
| 162 | shadow-color: black; | |
| 163 | } | |
| 164 | ||
| 165 | button:hover, | |
| 166 | input.submit:hover | |
| 167 | { | |
| 168 | background-image-t: 45px 90px; | |
| 169 | } | |
| 170 | ||
| 171 | button:active, | |
| 172 | input.submit:active | |
| 173 | { | |
| 174 | background-image-t: 90px 135px; | |
| 175 | } | |
| 176 | ||
| 177 | ||
| 178 | ||
| 179 | input.text | |
| 180 | { | |
| 181 | height: 31px; | |
| 182 | padding: 10px 10px 0px; | |
| 183 | ||
| 184 | background-decorator: tiled-horizontal; | |
| 185 | background-left-image: invader.tga 162px 192px 176px 223px; | |
| 186 | background-center-image: invader.tga stretch 176px 192px 177px 223px; | |
| 187 | } | |
| 188 | ||
| 189 | input.text, | |
| 190 | select, | |
| 191 | dataselect | |
| 192 | { | |
| 193 | color: black; | |
| 194 | font-size: 13; | |
| 195 | } | |
| 196 | ||
| 197 | datagrid input.text | |
| 198 | { | |
| 199 | width: 100%; | |
| 200 | height: auto; | |
| 201 | margin: 0px; | |
| 202 | padding: 0px 2px 0px; | |
| 203 | ||
| 204 | border-width: 1px; | |
| 205 | border-color: black; | |
| 206 | background-color: white; | |
| 207 | ||
| 208 | font-size: 15; | |
| 209 | ||
| 210 | background-decorator: none; | |
| 211 | } | |
| 212 | ||
| 213 | ||
| 214 | ||
| 215 | select, | |
| 216 | dataselect | |
| 217 | { | |
| 218 | width: 175px; | |
| 219 | height: 37px; | |
| 220 | } | |
| 221 | ||
| 222 | select selectvalue, | |
| 223 | dataselect selectvalue | |
| 224 | { | |
| 225 | width: auto; | |
| 226 | margin-right: 30px; | |
| 227 | ||
| 228 | height: 28px; | |
| 229 | padding: 9px 10px 0px 10px; | |
| 230 | ||
| 231 | background-decorator: image; | |
| 232 | background-image: invader.tga 162px 192px 307px 229px; | |
| 233 | } | |
| 234 | ||
| 235 | select selectvalue:hover, | |
| 236 | dataselect selectvalue:hover | |
| 237 | { | |
| 238 | background-image-t: 230px 267px; | |
| 239 | } | |
| 240 | ||
| 241 | select selectarrow, | |
| 242 | dataselect selectarrow | |
| 243 | { | |
| 244 | width: 30px; | |
| 245 | height: 37px; | |
| 246 | ||
| 247 | icon-decorator: image; | |
| 248 | icon-image: invader.tga 307px 192px 337px 229px; | |
| 249 | } | |
| 250 | ||
| 251 | select selectarrow:hover, | |
| 252 | dataselect selectarrow:hover | |
| 253 | { | |
| 254 | icon-image-t: 230px 267px; | |
| 255 | } | |
| 256 | ||
| 257 | select selectarrow:active, | |
| 258 | select selectarrow:checked, | |
| 259 | dataselect selectarrow:active, | |
| 260 | dataselect selectarrow:checked | |
| 261 | { | |
| 262 | icon-image-t: 268px 305px; | |
| 263 | } | |
| 264 | ||
| 265 | select selectbox, | |
| 266 | dataselect selectbox | |
| 267 | { | |
| 268 | margin-left: 1px; | |
| 269 | margin-top: -7px; | |
| 270 | width: 162px; | |
| 271 | padding: 1px 4px 4px 4px; | |
| 272 | } | |
| 273 | ||
| 274 | select selectbox, | |
| 275 | dataselect selectbox, | |
| 276 | datagrid datagridbody | |
| 277 | { | |
| 278 | background-decorator: tiled-box; | |
| 279 | background-top-left-image: invader.tga 281px 275px 292px 284px; | |
| 280 | background-top-right-image: invader.tga 294px 275px 305px 284px; | |
| 281 | background-top-image: invader.tga stretch 292px 275px 293px 284px; | |
| 282 | background-bottom-left-image: invader.tga 281px 285px 292px 296px; | |
| 283 | background-bottom-right-image: invader.tga 294px 285px 305px 296px; | |
| 284 | background-bottom-image: invader.tga stretch 292px 285px 293px 296px; | |
| 285 | background-left-image: invader.tga stretch 281px 283px 292px 284px; | |
| 286 | background-center-image: invader.tga stretch 292px 283px 293px 284px; | |
| 287 | } | |
| 288 | ||
| 289 | select selectbox option, | |
| 290 | dataselect selectbox option | |
| 291 | { | |
| 292 | width: auto; | |
| 293 | padding-left: 3px; | |
| 294 | } | |
| 295 | ||
| 296 | select selectbox option:nth-child(even), | |
| 297 | dataselect selectbox option:nth-child(even), | |
| 298 | datagrid datagridrow:nth-child(even) | |
| 299 | { | |
| 300 | background: #FFFFFFA0; | |
| 301 | } | |
| 302 | ||
| 303 | select selectbox option:hover, | |
| 304 | dataselect selectbox option:hover | |
| 305 | { | |
| 306 | background: #FF5D5D; | |
| 307 | } | |
| 308 | ||
| 309 | ||
| 310 | ||
| 311 | input.radio, | |
| 312 | input.checkbox | |
| 313 | { | |
| 314 | width: 30px; | |
| 315 | height: 30px; | |
| 316 | ||
| 317 | vertical-align: -11px; | |
| 318 | } | |
| 319 | ||
| 320 | input.radio | |
| 321 | { | |
| 322 | icon-decorator: image; | |
| 323 | icon-image: invader.tga 407px 0px 437px 30px; | |
| 324 | } | |
| 325 | ||
| 326 | input.radio:hover | |
| 327 | { | |
| 328 | icon-image-s: 437px 467px; | |
| 329 | } | |
| 330 | ||
| 331 | input.radio:active | |
| 332 | { | |
| 333 | icon-image-s: 467px 497px; | |
| 334 | } | |
| 335 | ||
| 336 | input.radio:checked | |
| 337 | { | |
| 338 | icon-image-t: 30px 60px; | |
| 339 | } | |
| 340 | ||
| 341 | input.radio:checked:hover | |
| 342 | { | |
| 343 | icon-image-s: 437px 467px; | |
| 344 | icon-image-t: 30px 60px; | |
| 345 | } | |
| 346 | ||
| 347 | input.radio:checked:active | |
| 348 | { | |
| 349 | icon-image-s: 467px 497px; | |
| 350 | icon-image-t: 30px 60px; | |
| 351 | } | |
| 352 | ||
| 353 | input.checkbox | |
| 354 | { | |
| 355 | icon-decorator: image; | |
| 356 | icon-image: invader.tga 407px 60px 437px 90px; | |
| 357 | } | |
| 358 | ||
| 359 | input.checkbox:hover | |
| 360 | { | |
| 361 | icon-image-s: 437px 467px; | |
| 362 | } | |
| 363 | ||
| 364 | input.checkbox:active | |
| 365 | { | |
| 366 | icon-image-s: 467px 497px; | |
| 367 | } | |
| 368 | ||
| 369 | input.checkbox:checked | |
| 370 | { | |
| 371 | icon-image-t: 90px 120px; | |
| 372 | } | |
| 373 | ||
| 374 | input.checkbox:checked:hover | |
| 375 | { | |
| 376 | icon-image-s: 437px 467px; | |
| 377 | icon-image-t: 90px 120px; | |
| 378 | } | |
| 379 | ||
| 380 | input.checkbox:checked:active | |
| 381 | { | |
| 382 | icon-image-s: 467px 497px; | |
| 383 | icon-image-t: 90px 120px; | |
| 384 | } | |
| 385 | ||
| 386 | ||
| 387 | ||
| 388 | datagrid datagridheader | |
| 389 | { | |
| 390 | width: auto; | |
| 391 | height: 25px; | |
| 392 | padding: 5px 10px 0px 10px; | |
| 393 | ||
| 394 | background-decorator: tiled-horizontal; | |
| 395 | background-left-image: invader.tga 127px 192px 143px 223px; | |
| 396 | background-center-image: invader.tga stretch 143px 192px 145px 223px; | |
| 397 | background-right-image: invader.tga 145px 192px 160px 223px; | |
| 398 | } | |
| 399 | ||
| 400 | datagrid datagridbody | |
| 401 | { | |
| 402 | color: black; | |
| 403 | ||
| 404 | margin-left: 4px; | |
| 405 | margin-right: 3px; | |
| 406 | padding: 0px 4px 4px 4px; | |
| 407 | } | |
| 408 | ||
| 409 | ||
| 410 | ||
| 411 | datagridexpand | |
| 412 | { | |
| 413 | display: block; | |
| 414 | ||
| 415 | margin: 1px 0px 1px 5px; | |
| 416 | height: 17px; | |
| 417 | width: 17px; | |
| 418 | ||
| 419 | icon-decorator: image; | |
| 420 | icon-image: invader.tga 3px 232px 20px 249px; | |
| 421 | } | |
| 422 | ||
| 423 | datagridexpand:hover | |
| 424 | { | |
| 425 | icon-image-s: 21px 38px; | |
| 426 | } | |
| 427 | ||
| 428 | datagridexpand:active | |
| 429 | { | |
| 430 | icon-image-s: 39px 56px; | |
| 431 | } | |
| 432 | ||
| 433 | datagridexpand.collapsed | |
| 434 | { | |
| 435 | icon-image-t: 250px 267px; | |
| 436 | } | |
| 437 | ||
| 438 | ||
| 439 | ||
| 440 | scrollbarvertical | |
| 441 | { | |
| 442 | margin-top: -6px; | |
| 443 | margin-bottom: -6px; | |
| 444 | margin-right: -11px; | |
| 445 | width: 27px; | |
| 446 | } | |
| 447 | ||
| 448 | scrollbarvertical slidertrack | |
| 449 | { | |
| 450 | background-decorator: tiled-vertical; | |
| 451 | background-top-image: invader.tga 70px 199px 97px 201px; | |
| 452 | background-center-image: invader.tga stretch 70px 201px 97px 202px; | |
| 453 | background-bottom-image: invader.tga 70px 203px 97px 204px; | |
| 454 | } | |
| 455 | ||
| 456 | scrollbarvertical sliderbar | |
| 457 | { | |
| 458 | margin-left: 4px; | |
| 459 | width: 23px; | |
| 460 | min-height: 46px; | |
| 461 | ||
| 462 | background-decorator: tiled-vertical; | |
| 463 | background-top-image: invader.tga 56px 152px 79px 175px; | |
| 464 | background-center-image: invader.tga stretch 56px 175px 79px 175px; | |
| 465 | background-bottom-image: invader.tga 56px 176px 79px 198px; | |
| 466 | } | |
| 467 | ||
| 468 | scrollbarvertical sliderbar:hover | |
| 469 | { | |
| 470 | background-top-image-s: 80px 103px; | |
| 471 | background-center-image-s: 80px 103px; | |
| 472 | background-bottom-image-s: 80px 103px; | |
| 473 | } | |
| 474 | ||
| 475 | scrollbarvertical sliderbar:active | |
| 476 | { | |
| 477 | background-top-image-s: 104px 127px; | |
| 478 | background-center-image-s: 104px 127px; | |
| 479 | background-bottom-image-s: 104px 127px; | |
| 480 | } | |
| 481 | ||
| 482 | scrollbarvertical sliderarrowdec | |
| 483 | { | |
| 484 | width: 27px; | |
| 485 | height: 24px; | |
| 486 | ||
| 487 | icon-decorator: image; | |
| 488 | icon-image: invader.tga 0px 152px 27px 176px; | |
| 489 | } | |
| 490 | ||
| 491 | scrollbarvertical sliderarrowdec:hover, | |
| 492 | scrollbarvertical sliderarrowinc:hover | |
| 493 | { | |
| 494 | icon-image-t: 177px 201px; | |
| 495 | } | |
| 496 | ||
| 497 | scrollbarvertical sliderarrowdec:active, | |
| 498 | scrollbarvertical sliderarrowinc:active | |
| 499 | { | |
| 500 | icon-image-t: 202px 226px; | |
| 501 | } | |
| 502 | ||
| 503 | scrollbarvertical sliderarrowinc | |
| 504 | { | |
| 505 | width: 27px; | |
| 506 | height: 24px; | |
| 507 | ||
| 508 | icon-decorator: image; | |
| 509 | icon-image: invader.tga 28px 152px 55px 176px; | |
| 510 | } | |
| 511 | ||
| 512 | ||
| 513 | ||
| 514 | scrollbarhorizontal | |
| 515 | { | |
| 516 | width: 0px; | |
| 517 | height: 0px; | |
| 518 | } |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| Added: svn:mime-type + application/octet-stream |
| Added: svn:mime-type + application/octet-stream |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * Default styles for all the basic elements. | |
| 3 | */ | |
| 4 | ||
| 5 | div | |
| 6 | { | |
| 7 | display: block; | |
| 8 | } | |
| 9 | ||
| 10 | p | |
| 11 | { | |
| 12 | display: block; | |
| 13 | } | |
| 14 | ||
| 15 | h1 | |
| 16 | { | |
| 17 | display: block; | |
| 18 | } | |
| 19 | ||
| 20 | em | |
| 21 | { | |
| 22 | font-style: italic; | |
| 23 | } | |
| 24 | ||
| 25 | strong | |
| 26 | { | |
| 27 | font-weight: bold; | |
| 28 | } | |
| 29 | ||
| 30 | datagrid | |
| 31 | { | |
| 32 | display: block; | |
| 33 | } | |
| 34 | ||
| 35 | select, dataselect, datacombo | |
| 36 | { | |
| 37 | text-align: left; | |
| 38 | } | |
| 39 | ||
| 40 | tabset tabs | |
| 41 | { | |
| 42 | display: block; | |
| 43 | } | |
| 44 |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| Added: svn:mime-type + application/octet-stream |
| Added: svn:mime-type + application/octet-stream |
| r23952 | r23953 | |
|---|---|---|
| 1 | #ifndef __FT2_BUILD_UNIX_H__ | |
| 2 | #define __FT2_BUILD_UNIX_H__ | |
| 3 | ||
| 4 | /* `<prefix>/include/freetype2' must be in your current inclusion path */ | |
| 5 | #include "freetype/config/ftheader.h" | |
| 6 | ||
| 7 | #endif /* __FT2_BUILD_UNIX_H__ */ | |
| 8 | ||
| 9 | ||
| 10 | /* END */ |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef ROCKETSHELLOPENGL_H | |
| 29 | #define ROCKETSHELLOPENGL_H | |
| 30 | ||
| 31 | #include <Rocket/Core/Platform.h> | |
| 32 | ||
| 33 | #if defined ROCKET_PLATFORM_WIN32 | |
| 34 | #define WIN32_LEAN_AND_MEAN | |
| 35 | #include <windows.h> | |
| 36 | #include <gl/Gl.h> | |
| 37 | #include <gl/Glu.h> | |
| 38 | #elif defined ROCKET_PLATFORM_MACOSX | |
| 39 | #include <OpenGL/gl.h> | |
| 40 | #include <OpenGL/glu.h> | |
| 41 | #include <OpenGL/glext.h> | |
| 42 | #elif defined ROCKET_PLATFORM_UNIX | |
| 43 | #include <GL/gl.h> | |
| 44 | #include <GL/glext.h> | |
| 45 | #include <GL/glu.h> | |
| 46 | #endif | |
| 47 | ||
| 48 | #endif |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <win32/InputWin32.h> | |
| 29 | #include <Rocket/Core/Context.h> | |
| 30 | #include <Rocket/Core/Input.h> | |
| 31 | #include <Rocket/Debugger.h> | |
| 32 | #include <Shell.h> | |
| 33 | ||
| 34 | static int GetKeyModifierState(); | |
| 35 | static void InitialiseKeymap(); | |
| 36 | ||
| 37 | static const int KEYMAP_SIZE = 256; | |
| 38 | static Rocket::Core::Input::KeyIdentifier key_identifier_map[KEYMAP_SIZE]; | |
| 39 | ||
| 40 | bool InputWin32::Initialise() | |
| 41 | { | |
| 42 | InitialiseKeymap(); | |
| 43 | return true; | |
| 44 | } | |
| 45 | ||
| 46 | void InputWin32::Shutdown() | |
| 47 | { | |
| 48 | } | |
| 49 | ||
| 50 | void InputWin32::ProcessWindowsEvent(UINT message, WPARAM w_param, LPARAM l_param) | |
| 51 | { | |
| 52 | if (context == NULL) | |
| 53 | return; | |
| 54 | ||
| 55 | // Process all mouse and keyboard events | |
| 56 | switch (message) | |
| 57 | { | |
| 58 | case WM_LBUTTONDOWN: | |
| 59 | context->ProcessMouseButtonDown(0, GetKeyModifierState()); | |
| 60 | break; | |
| 61 | ||
| 62 | case WM_LBUTTONUP: | |
| 63 | context->ProcessMouseButtonUp(0, GetKeyModifierState()); | |
| 64 | break; | |
| 65 | ||
| 66 | case WM_RBUTTONDOWN: | |
| 67 | context->ProcessMouseButtonDown(1, GetKeyModifierState()); | |
| 68 | break; | |
| 69 | ||
| 70 | case WM_RBUTTONUP: | |
| 71 | context->ProcessMouseButtonUp(1, GetKeyModifierState()); | |
| 72 | break; | |
| 73 | ||
| 74 | case WM_MBUTTONDOWN: | |
| 75 | context->ProcessMouseButtonDown(2, GetKeyModifierState()); | |
| 76 | break; | |
| 77 | ||
| 78 | case WM_MBUTTONUP: | |
| 79 | context->ProcessMouseButtonUp(2, GetKeyModifierState()); | |
| 80 | break; | |
| 81 | ||
| 82 | case WM_MOUSEMOVE: | |
| 83 | context->ProcessMouseMove(LOWORD(l_param), HIWORD(l_param), GetKeyModifierState()); | |
| 84 | break; | |
| 85 | ||
| 86 | case WM_MOUSEWHEEL: | |
| 87 | context->ProcessMouseWheel(((short) HIWORD(w_param)) / -WHEEL_DELTA, GetKeyModifierState()); | |
| 88 | break; | |
| 89 | ||
| 90 | case WM_KEYDOWN: | |
| 91 | { | |
| 92 | Rocket::Core::Input::KeyIdentifier key_identifier = key_identifier_map[w_param]; | |
| 93 | int key_modifier_state = GetKeyModifierState(); | |
| 94 | ||
| 95 | // Check for a shift-~ to toggle the debugger. | |
| 96 | if (key_identifier == Rocket::Core::Input::KI_OEM_3 && | |
| 97 | key_modifier_state & Rocket::Core::Input::KM_SHIFT) | |
| 98 | { | |
| 99 | Rocket::Debugger::SetVisible(!Rocket::Debugger::IsVisible()); | |
| 100 | break; | |
| 101 | } | |
| 102 | ||
| 103 | context->ProcessKeyDown(key_identifier, key_modifier_state); | |
| 104 | } | |
| 105 | break; | |
| 106 | ||
| 107 | case WM_CHAR: | |
| 108 | { | |
| 109 | // Only send through printable characters. | |
| 110 | if (w_param >= 32) | |
| 111 | context->ProcessTextInput((Rocket::Core::word) w_param); | |
| 112 | // Or endlines - Windows sends them through as carriage returns. | |
| 113 | else if (w_param == '\r') | |
| 114 | context->ProcessTextInput((Rocket::Core::word) '\n'); | |
| 115 | } | |
| 116 | break; | |
| 117 | ||
| 118 | case WM_KEYUP: | |
| 119 | context->ProcessKeyUp(key_identifier_map[w_param], GetKeyModifierState()); | |
| 120 | break; | |
| 121 | } | |
| 122 | } | |
| 123 | ||
| 124 | static int GetKeyModifierState() | |
| 125 | { | |
| 126 | int key_modifier_state = 0; | |
| 127 | ||
| 128 | // Query the state of all modifier keys | |
| 129 | if (GetKeyState(VK_CAPITAL) & 1) | |
| 130 | { | |
| 131 | key_modifier_state |= Rocket::Core::Input::KM_CAPSLOCK; | |
| 132 | } | |
| 133 | ||
| 134 | if (HIWORD(GetKeyState(VK_SHIFT)) & 1) | |
| 135 | { | |
| 136 | key_modifier_state |= Rocket::Core::Input::KM_SHIFT; | |
| 137 | } | |
| 138 | ||
| 139 | if (GetKeyState(VK_NUMLOCK) & 1) | |
| 140 | { | |
| 141 | key_modifier_state |= Rocket::Core::Input::KM_NUMLOCK; | |
| 142 | } | |
| 143 | ||
| 144 | if (HIWORD(GetKeyState(VK_CONTROL)) & 1) | |
| 145 | { | |
| 146 | key_modifier_state |= Rocket::Core::Input::KM_CTRL; | |
| 147 | } | |
| 148 | ||
| 149 | if (HIWORD(GetKeyState(VK_MENU)) & 1) | |
| 150 | { | |
| 151 | key_modifier_state |= Rocket::Core::Input::KM_ALT; | |
| 152 | } | |
| 153 | ||
| 154 | return key_modifier_state; | |
| 155 | } | |
| 156 | ||
| 157 | static void InitialiseKeymap() | |
| 158 | { | |
| 159 | // Initialise the key map with default values. | |
| 160 | memset(key_identifier_map, 0, sizeof(key_identifier_map)); | |
| 161 | ||
| 162 | // Assign individual values. | |
| 163 | key_identifier_map['A'] = Rocket::Core::Input::KI_A; | |
| 164 | key_identifier_map['B'] = Rocket::Core::Input::KI_B; | |
| 165 | key_identifier_map['C'] = Rocket::Core::Input::KI_C; | |
| 166 | key_identifier_map['D'] = Rocket::Core::Input::KI_D; | |
| 167 | key_identifier_map['E'] = Rocket::Core::Input::KI_E; | |
| 168 | key_identifier_map['F'] = Rocket::Core::Input::KI_F; | |
| 169 | key_identifier_map['G'] = Rocket::Core::Input::KI_G; | |
| 170 | key_identifier_map['H'] = Rocket::Core::Input::KI_H; | |
| 171 | key_identifier_map['I'] = Rocket::Core::Input::KI_I; | |
| 172 | key_identifier_map['J'] = Rocket::Core::Input::KI_J; | |
| 173 | key_identifier_map['K'] = Rocket::Core::Input::KI_K; | |
| 174 | key_identifier_map['L'] = Rocket::Core::Input::KI_L; | |
| 175 | key_identifier_map['M'] = Rocket::Core::Input::KI_M; | |
| 176 | key_identifier_map['N'] = Rocket::Core::Input::KI_N; | |
| 177 | key_identifier_map['O'] = Rocket::Core::Input::KI_O; | |
| 178 | key_identifier_map['P'] = Rocket::Core::Input::KI_P; | |
| 179 | key_identifier_map['Q'] = Rocket::Core::Input::KI_Q; | |
| 180 | key_identifier_map['R'] = Rocket::Core::Input::KI_R; | |
| 181 | key_identifier_map['S'] = Rocket::Core::Input::KI_S; | |
| 182 | key_identifier_map['T'] = Rocket::Core::Input::KI_T; | |
| 183 | key_identifier_map['U'] = Rocket::Core::Input::KI_U; | |
| 184 | key_identifier_map['V'] = Rocket::Core::Input::KI_V; | |
| 185 | key_identifier_map['W'] = Rocket::Core::Input::KI_W; | |
| 186 | key_identifier_map['X'] = Rocket::Core::Input::KI_X; | |
| 187 | key_identifier_map['Y'] = Rocket::Core::Input::KI_Y; | |
| 188 | key_identifier_map['Z'] = Rocket::Core::Input::KI_Z; | |
| 189 | ||
| 190 | key_identifier_map['0'] = Rocket::Core::Input::KI_0; | |
| 191 | key_identifier_map['1'] = Rocket::Core::Input::KI_1; | |
| 192 | key_identifier_map['2'] = Rocket::Core::Input::KI_2; | |
| 193 | key_identifier_map['3'] = Rocket::Core::Input::KI_3; | |
| 194 | key_identifier_map['4'] = Rocket::Core::Input::KI_4; | |
| 195 | key_identifier_map['5'] = Rocket::Core::Input::KI_5; | |
| 196 | key_identifier_map['6'] = Rocket::Core::Input::KI_6; | |
| 197 | key_identifier_map['7'] = Rocket::Core::Input::KI_7; | |
| 198 | key_identifier_map['8'] = Rocket::Core::Input::KI_8; | |
| 199 | key_identifier_map['9'] = Rocket::Core::Input::KI_9; | |
| 200 | ||
| 201 | key_identifier_map[VK_BACK] = Rocket::Core::Input::KI_BACK; | |
| 202 | key_identifier_map[VK_TAB] = Rocket::Core::Input::KI_TAB; | |
| 203 | ||
| 204 | key_identifier_map[VK_CLEAR] = Rocket::Core::Input::KI_CLEAR; | |
| 205 | key_identifier_map[VK_RETURN] = Rocket::Core::Input::KI_RETURN; | |
| 206 | ||
| 207 | key_identifier_map[VK_PAUSE] = Rocket::Core::Input::KI_PAUSE; | |
| 208 | key_identifier_map[VK_CAPITAL] = Rocket::Core::Input::KI_CAPITAL; | |
| 209 | ||
| 210 | key_identifier_map[VK_KANA] = Rocket::Core::Input::KI_KANA; | |
| 211 | key_identifier_map[VK_HANGUL] = Rocket::Core::Input::KI_HANGUL; | |
| 212 | key_identifier_map[VK_JUNJA] = Rocket::Core::Input::KI_JUNJA; | |
| 213 | key_identifier_map[VK_FINAL] = Rocket::Core::Input::KI_FINAL; | |
| 214 | key_identifier_map[VK_HANJA] = Rocket::Core::Input::KI_HANJA; | |
| 215 | key_identifier_map[VK_KANJI] = Rocket::Core::Input::KI_KANJI; | |
| 216 | ||
| 217 | key_identifier_map[VK_ESCAPE] = Rocket::Core::Input::KI_ESCAPE; | |
| 218 | ||
| 219 | key_identifier_map[VK_CONVERT] = Rocket::Core::Input::KI_CONVERT; | |
| 220 | key_identifier_map[VK_NONCONVERT] = Rocket::Core::Input::KI_NONCONVERT; | |
| 221 | key_identifier_map[VK_ACCEPT] = Rocket::Core::Input::KI_ACCEPT; | |
| 222 | key_identifier_map[VK_MODECHANGE] = Rocket::Core::Input::KI_MODECHANGE; | |
| 223 | ||
| 224 | key_identifier_map[VK_SPACE] = Rocket::Core::Input::KI_SPACE; | |
| 225 | key_identifier_map[VK_PRIOR] = Rocket::Core::Input::KI_PRIOR; | |
| 226 | key_identifier_map[VK_NEXT] = Rocket::Core::Input::KI_NEXT; | |
| 227 | key_identifier_map[VK_END] = Rocket::Core::Input::KI_END; | |
| 228 | key_identifier_map[VK_HOME] = Rocket::Core::Input::KI_HOME; | |
| 229 | key_identifier_map[VK_LEFT] = Rocket::Core::Input::KI_LEFT; | |
| 230 | key_identifier_map[VK_UP] = Rocket::Core::Input::KI_UP; | |
| 231 | key_identifier_map[VK_RIGHT] = Rocket::Core::Input::KI_RIGHT; | |
| 232 | key_identifier_map[VK_DOWN] = Rocket::Core::Input::KI_DOWN; | |
| 233 | key_identifier_map[VK_SELECT] = Rocket::Core::Input::KI_SELECT; | |
| 234 | key_identifier_map[VK_PRINT] = Rocket::Core::Input::KI_PRINT; | |
| 235 | key_identifier_map[VK_EXECUTE] = Rocket::Core::Input::KI_EXECUTE; | |
| 236 | key_identifier_map[VK_SNAPSHOT] = Rocket::Core::Input::KI_SNAPSHOT; | |
| 237 | key_identifier_map[VK_INSERT] = Rocket::Core::Input::KI_INSERT; | |
| 238 | key_identifier_map[VK_DELETE] = Rocket::Core::Input::KI_DELETE; | |
| 239 | key_identifier_map[VK_HELP] = Rocket::Core::Input::KI_HELP; | |
| 240 | ||
| 241 | key_identifier_map[VK_LWIN] = Rocket::Core::Input::KI_LWIN; | |
| 242 | key_identifier_map[VK_RWIN] = Rocket::Core::Input::KI_RWIN; | |
| 243 | key_identifier_map[VK_APPS] = Rocket::Core::Input::KI_APPS; | |
| 244 | ||
| 245 | key_identifier_map[VK_SLEEP] = Rocket::Core::Input::KI_SLEEP; | |
| 246 | ||
| 247 | key_identifier_map[VK_NUMPAD0] = Rocket::Core::Input::KI_NUMPAD0; | |
| 248 | key_identifier_map[VK_NUMPAD1] = Rocket::Core::Input::KI_NUMPAD1; | |
| 249 | key_identifier_map[VK_NUMPAD2] = Rocket::Core::Input::KI_NUMPAD2; | |
| 250 | key_identifier_map[VK_NUMPAD3] = Rocket::Core::Input::KI_NUMPAD3; | |
| 251 | key_identifier_map[VK_NUMPAD4] = Rocket::Core::Input::KI_NUMPAD4; | |
| 252 | key_identifier_map[VK_NUMPAD5] = Rocket::Core::Input::KI_NUMPAD5; | |
| 253 | key_identifier_map[VK_NUMPAD6] = Rocket::Core::Input::KI_NUMPAD6; | |
| 254 | key_identifier_map[VK_NUMPAD7] = Rocket::Core::Input::KI_NUMPAD7; | |
| 255 | key_identifier_map[VK_NUMPAD8] = Rocket::Core::Input::KI_NUMPAD8; | |
| 256 | key_identifier_map[VK_NUMPAD9] = Rocket::Core::Input::KI_NUMPAD9; | |
| 257 | key_identifier_map[VK_MULTIPLY] = Rocket::Core::Input::KI_MULTIPLY; | |
| 258 | key_identifier_map[VK_ADD] = Rocket::Core::Input::KI_ADD; | |
| 259 | key_identifier_map[VK_SEPARATOR] = Rocket::Core::Input::KI_SEPARATOR; | |
| 260 | key_identifier_map[VK_SUBTRACT] = Rocket::Core::Input::KI_SUBTRACT; | |
| 261 | key_identifier_map[VK_DECIMAL] = Rocket::Core::Input::KI_DECIMAL; | |
| 262 | key_identifier_map[VK_DIVIDE] = Rocket::Core::Input::KI_DIVIDE; | |
| 263 | key_identifier_map[VK_F1] = Rocket::Core::Input::KI_F1; | |
| 264 | key_identifier_map[VK_F2] = Rocket::Core::Input::KI_F2; | |
| 265 | key_identifier_map[VK_F3] = Rocket::Core::Input::KI_F3; | |
| 266 | key_identifier_map[VK_F4] = Rocket::Core::Input::KI_F4; | |
| 267 | key_identifier_map[VK_F5] = Rocket::Core::Input::KI_F5; | |
| 268 | key_identifier_map[VK_F6] = Rocket::Core::Input::KI_F6; | |
| 269 | key_identifier_map[VK_F7] = Rocket::Core::Input::KI_F7; | |
| 270 | key_identifier_map[VK_F8] = Rocket::Core::Input::KI_F8; | |
| 271 | key_identifier_map[VK_F9] = Rocket::Core::Input::KI_F9; | |
| 272 | key_identifier_map[VK_F10] = Rocket::Core::Input::KI_F10; | |
| 273 | key_identifier_map[VK_F11] = Rocket::Core::Input::KI_F11; | |
| 274 | key_identifier_map[VK_F12] = Rocket::Core::Input::KI_F12; | |
| 275 | key_identifier_map[VK_F13] = Rocket::Core::Input::KI_F13; | |
| 276 | key_identifier_map[VK_F14] = Rocket::Core::Input::KI_F14; | |
| 277 | key_identifier_map[VK_F15] = Rocket::Core::Input::KI_F15; | |
| 278 | key_identifier_map[VK_F16] = Rocket::Core::Input::KI_F16; | |
| 279 | key_identifier_map[VK_F17] = Rocket::Core::Input::KI_F17; | |
| 280 | key_identifier_map[VK_F18] = Rocket::Core::Input::KI_F18; | |
| 281 | key_identifier_map[VK_F19] = Rocket::Core::Input::KI_F19; | |
| 282 | key_identifier_map[VK_F20] = Rocket::Core::Input::KI_F20; | |
| 283 | key_identifier_map[VK_F21] = Rocket::Core::Input::KI_F21; | |
| 284 | key_identifier_map[VK_F22] = Rocket::Core::Input::KI_F22; | |
| 285 | key_identifier_map[VK_F23] = Rocket::Core::Input::KI_F23; | |
| 286 | key_identifier_map[VK_F24] = Rocket::Core::Input::KI_F24; | |
| 287 | ||
| 288 | key_identifier_map[VK_NUMLOCK] = Rocket::Core::Input::KI_NUMLOCK; | |
| 289 | key_identifier_map[VK_SCROLL] = Rocket::Core::Input::KI_SCROLL; | |
| 290 | ||
| 291 | key_identifier_map[VK_OEM_NEC_EQUAL] = Rocket::Core::Input::KI_OEM_NEC_EQUAL; | |
| 292 | ||
| 293 | key_identifier_map[VK_OEM_FJ_JISHO] = Rocket::Core::Input::KI_OEM_FJ_JISHO; | |
| 294 | key_identifier_map[VK_OEM_FJ_MASSHOU] = Rocket::Core::Input::KI_OEM_FJ_MASSHOU; | |
| 295 | key_identifier_map[VK_OEM_FJ_TOUROKU] = Rocket::Core::Input::KI_OEM_FJ_TOUROKU; | |
| 296 | key_identifier_map[VK_OEM_FJ_LOYA] = Rocket::Core::Input::KI_OEM_FJ_LOYA; | |
| 297 | key_identifier_map[VK_OEM_FJ_ROYA] = Rocket::Core::Input::KI_OEM_FJ_ROYA; | |
| 298 | ||
| 299 | key_identifier_map[VK_SHIFT] = Rocket::Core::Input::KI_LSHIFT; | |
| 300 | key_identifier_map[VK_CONTROL] = Rocket::Core::Input::KI_LCONTROL; | |
| 301 | key_identifier_map[VK_MENU] = Rocket::Core::Input::KI_LMENU; | |
| 302 | ||
| 303 | key_identifier_map[VK_BROWSER_BACK] = Rocket::Core::Input::KI_BROWSER_BACK; | |
| 304 | key_identifier_map[VK_BROWSER_FORWARD] = Rocket::Core::Input::KI_BROWSER_FORWARD; | |
| 305 | key_identifier_map[VK_BROWSER_REFRESH] = Rocket::Core::Input::KI_BROWSER_REFRESH; | |
| 306 | key_identifier_map[VK_BROWSER_STOP] = Rocket::Core::Input::KI_BROWSER_STOP; | |
| 307 | key_identifier_map[VK_BROWSER_SEARCH] = Rocket::Core::Input::KI_BROWSER_SEARCH; | |
| 308 | key_identifier_map[VK_BROWSER_FAVORITES] = Rocket::Core::Input::KI_BROWSER_FAVORITES; | |
| 309 | key_identifier_map[VK_BROWSER_HOME] = Rocket::Core::Input::KI_BROWSER_HOME; | |
| 310 | ||
| 311 | key_identifier_map[VK_VOLUME_MUTE] = Rocket::Core::Input::KI_VOLUME_MUTE; | |
| 312 | key_identifier_map[VK_VOLUME_DOWN] = Rocket::Core::Input::KI_VOLUME_DOWN; | |
| 313 | key_identifier_map[VK_VOLUME_UP] = Rocket::Core::Input::KI_VOLUME_UP; | |
| 314 | key_identifier_map[VK_MEDIA_NEXT_TRACK] = Rocket::Core::Input::KI_MEDIA_NEXT_TRACK; | |
| 315 | key_identifier_map[VK_MEDIA_PREV_TRACK] = Rocket::Core::Input::KI_MEDIA_PREV_TRACK; | |
| 316 | key_identifier_map[VK_MEDIA_STOP] = Rocket::Core::Input::KI_MEDIA_STOP; | |
| 317 | key_identifier_map[VK_MEDIA_PLAY_PAUSE] = Rocket::Core::Input::KI_MEDIA_PLAY_PAUSE; | |
| 318 | key_identifier_map[VK_LAUNCH_MAIL] = Rocket::Core::Input::KI_LAUNCH_MAIL; | |
| 319 | key_identifier_map[VK_LAUNCH_MEDIA_SELECT] = Rocket::Core::Input::KI_LAUNCH_MEDIA_SELECT; | |
| 320 | key_identifier_map[VK_LAUNCH_APP1] = Rocket::Core::Input::KI_LAUNCH_APP1; | |
| 321 | key_identifier_map[VK_LAUNCH_APP2] = Rocket::Core::Input::KI_LAUNCH_APP2; | |
| 322 | ||
| 323 | key_identifier_map[VK_OEM_1] = Rocket::Core::Input::KI_OEM_1; | |
| 324 | key_identifier_map[VK_OEM_PLUS] = Rocket::Core::Input::KI_OEM_PLUS; | |
| 325 | key_identifier_map[VK_OEM_COMMA] = Rocket::Core::Input::KI_OEM_COMMA; | |
| 326 | key_identifier_map[VK_OEM_MINUS] = Rocket::Core::Input::KI_OEM_MINUS; | |
| 327 | key_identifier_map[VK_OEM_PERIOD] = Rocket::Core::Input::KI_OEM_PERIOD; | |
| 328 | key_identifier_map[VK_OEM_2] = Rocket::Core::Input::KI_OEM_2; | |
| 329 | key_identifier_map[VK_OEM_3] = Rocket::Core::Input::KI_OEM_3; | |
| 330 | ||
| 331 | key_identifier_map[VK_OEM_4] = Rocket::Core::Input::KI_OEM_4; | |
| 332 | key_identifier_map[VK_OEM_5] = Rocket::Core::Input::KI_OEM_5; | |
| 333 | key_identifier_map[VK_OEM_6] = Rocket::Core::Input::KI_OEM_6; | |
| 334 | key_identifier_map[VK_OEM_7] = Rocket::Core::Input::KI_OEM_7; | |
| 335 | key_identifier_map[VK_OEM_8] = Rocket::Core::Input::KI_OEM_8; | |
| 336 | ||
| 337 | key_identifier_map[VK_OEM_AX] = Rocket::Core::Input::KI_OEM_AX; | |
| 338 | key_identifier_map[VK_OEM_102] = Rocket::Core::Input::KI_OEM_102; | |
| 339 | key_identifier_map[VK_ICO_HELP] = Rocket::Core::Input::KI_ICO_HELP; | |
| 340 | key_identifier_map[VK_ICO_00] = Rocket::Core::Input::KI_ICO_00; | |
| 341 | ||
| 342 | key_identifier_map[VK_PROCESSKEY] = Rocket::Core::Input::KI_PROCESSKEY; | |
| 343 | ||
| 344 | key_identifier_map[VK_ICO_CLEAR] = Rocket::Core::Input::KI_ICO_CLEAR; | |
| 345 | ||
| 346 | key_identifier_map[VK_ATTN] = Rocket::Core::Input::KI_ATTN; | |
| 347 | key_identifier_map[VK_CRSEL] = Rocket::Core::Input::KI_CRSEL; | |
| 348 | key_identifier_map[VK_EXSEL] = Rocket::Core::Input::KI_EXSEL; | |
| 349 | key_identifier_map[VK_EREOF] = Rocket::Core::Input::KI_EREOF; | |
| 350 | key_identifier_map[VK_PLAY] = Rocket::Core::Input::KI_PLAY; | |
| 351 | key_identifier_map[VK_ZOOM] = Rocket::Core::Input::KI_ZOOM; | |
| 352 | key_identifier_map[VK_PA1] = Rocket::Core::Input::KI_PA1; | |
| 353 | key_identifier_map[VK_OEM_CLEAR] = Rocket::Core::Input::KI_OEM_CLEAR; | |
| 354 | } |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef ROCKETINPUTWIN32_H | |
| 29 | #define ROCKETINPUTWIN32_H | |
| 30 | ||
| 31 | #include <RocketInput.h> | |
| 32 | #if !defined _WIN32_WINNT || _WIN32_WINNT < 0x0500 | |
| 33 | #undef _WIN32_WINNT | |
| 34 | #define _WIN32_WINNT 0x0500 | |
| 35 | #endif | |
| 36 | #include <windows.h> | |
| 37 | ||
| 38 | /** | |
| 39 | Processes Windows input events and passes them through to Rocket. Feel free to take this class and integrate it | |
| 40 | with your project. | |
| 41 | @author Lloyd Weehuizen | |
| 42 | */ | |
| 43 | ||
| 44 | class InputWin32 : public Input | |
| 45 | { | |
| 46 | public: | |
| 47 | static bool Initialise(); | |
| 48 | static void Shutdown(); | |
| 49 | ||
| 50 | /// Process the Windows message. | |
| 51 | static void ProcessWindowsEvent(UINT message, WPARAM w_param, LPARAM l_param); | |
| 52 | private: | |
| 53 | }; | |
| 54 | ||
| 55 | #endif |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <Shell.h> | |
| 29 | #include <Rocket/Core.h> | |
| 30 | #include <win32/InputWin32.h> | |
| 31 | #include "ShellFileInterface.h" | |
| 32 | #include <windows.h> | |
| 33 | #include <stdio.h> | |
| 34 | #include "strconv.h" | |
| 35 | ||
| 36 | static bool AttachOpenGL(); | |
| 37 | static void DetachOpenGL(); | |
| 38 | static LRESULT CALLBACK WindowProcedure(HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param); | |
| 39 | ||
| 40 | static bool activated = true; | |
| 41 | static bool running = false; | |
| 42 | static bool opengl_attached = false; | |
| 43 | static const char* instance_name = NULL; | |
| 44 | static HWND window_handle = NULL; | |
| 45 | static HINSTANCE instance_handle = NULL; | |
| 46 | static HDC device_context = NULL; | |
| 47 | static HGLRC render_context = NULL; | |
| 48 | ||
| 49 | static double time_frequency; | |
| 50 | static LARGE_INTEGER time_startup; | |
| 51 | ||
| 52 | static ShellFileInterface* file_interface = NULL; | |
| 53 | ||
| 54 | bool Shell::Initialise(const Rocket::Core::String& path) | |
| 55 | { | |
| 56 | instance_handle = GetModuleHandle(NULL); | |
| 57 | InputWin32::Initialise(); | |
| 58 | ||
| 59 | LARGE_INTEGER time_ticks_per_second; | |
| 60 | QueryPerformanceFrequency(&time_ticks_per_second); | |
| 61 | QueryPerformanceCounter(&time_startup); | |
| 62 | ||
| 63 | time_frequency = 1.0 / (double) time_ticks_per_second.QuadPart; | |
| 64 | ||
| 65 | // Fetch the path of the executable, append the path onto that. | |
| 66 | char executable_file_name[MAX_PATH]; | |
| 67 | if (GetModuleFileNameA(instance_handle, executable_file_name, MAX_PATH) >= MAX_PATH && | |
| 68 | GetLastError() == ERROR_INSUFFICIENT_BUFFER) | |
| 69 | executable_file_name[0] = 0; | |
| 70 | ||
| 71 | executable_path = Rocket::Core::String(executable_file_name); | |
| 72 | executable_path = executable_path.Substring(0, executable_path.RFind("\\") + 1); | |
| 73 | file_interface = new ShellFileInterface(executable_path + path); | |
| 74 | Rocket::Core::SetFileInterface(file_interface); | |
| 75 | ||
| 76 | return true; | |
| 77 | } | |
| 78 | ||
| 79 | void Shell::Shutdown() | |
| 80 | { | |
| 81 | InputWin32::Shutdown(); | |
| 82 | ||
| 83 | delete file_interface; | |
| 84 | file_interface = NULL; | |
| 85 | } | |
| 86 | ||
| 87 | bool Shell::OpenWindow(const char* name, bool attach_opengl) | |
| 88 | { | |
| 89 | WNDCLASS window_class; | |
| 90 | ||
| 91 | // Fill out the window class struct. | |
| 92 | window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; | |
| 93 | window_class.lpfnWndProc = WindowProcedure; | |
| 94 | window_class.cbClsExtra = 0; | |
| 95 | window_class.cbWndExtra = 0; | |
| 96 | window_class.hInstance = instance_handle; | |
| 97 | window_class.hIcon = LoadIcon(NULL, IDI_WINLOGO); | |
| 98 | window_class.hCursor = LoadCursor(NULL, IDC_ARROW); | |
| 99 | window_class.hbrBackground = NULL; | |
| 100 | window_class.lpszMenuName = NULL; | |
| 101 | window_class.lpszClassName = tstring_from_utf8(name); | |
| 102 | ||
| 103 | if (!RegisterClass(&window_class)) | |
| 104 | { | |
| 105 | DisplayError("Could not register window class."); | |
| 106 | ||
| 107 | CloseWindow(); | |
| 108 | return false; | |
| 109 | } | |
| 110 | ||
| 111 | window_handle = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, | |
| 112 | tstring_from_utf8(name), // Window class name. | |
| 113 | tstring_from_utf8(name), | |
| 114 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW, | |
| 115 | 0, 0, // Window position. | |
| 116 | 0, 0, // Window size. | |
| 117 | NULL, | |
| 118 | NULL, | |
| 119 | instance_handle, | |
| 120 | NULL); | |
| 121 | if (!window_handle) | |
| 122 | { | |
| 123 | DisplayError("Could not create window."); | |
| 124 | CloseWindow(); | |
| 125 | ||
| 126 | return false; | |
| 127 | } | |
| 128 | ||
| 129 | instance_name = name; | |
| 130 | ||
| 131 | DWORD style = WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_MAXIMIZEBOX; | |
| 132 | DWORD extended_style = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; | |
| 133 | ||
| 134 | // Adjust the window size to take into account the edges | |
| 135 | RECT window_rect; | |
| 136 | window_rect.top = 0; | |
| 137 | window_rect.left = 0; | |
| 138 | window_rect.right = 1024; | |
| 139 | window_rect.bottom = 768; | |
| 140 | AdjustWindowRectEx(&window_rect, style, FALSE, extended_style); | |
| 141 | ||
| 142 | SetWindowLong(window_handle, GWL_EXSTYLE, extended_style); | |
| 143 | SetWindowLong(window_handle, GWL_STYLE, style); | |
| 144 | ||
| 145 | // Resize the window. | |
| 146 | SetWindowPos(window_handle, HWND_TOP, 0, 0, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, SWP_NOACTIVATE); | |
| 147 | ||
| 148 | // Display the new window | |
| 149 | ShowWindow(window_handle, SW_SHOW); | |
| 150 | SetForegroundWindow(window_handle); | |
| 151 | SetFocus(window_handle); | |
| 152 | ||
| 153 | // Attach OpenGL if necessary | |
| 154 | if (attach_opengl) | |
| 155 | { | |
| 156 | opengl_attached = AttachOpenGL(); | |
| 157 | if (!opengl_attached) | |
| 158 | return false; | |
| 159 | } | |
| 160 | ||
| 161 | return true; | |
| 162 | } | |
| 163 | ||
| 164 | void Shell::CloseWindow() | |
| 165 | { | |
| 166 | // Shutdown opengl if necessary | |
| 167 | if (opengl_attached) | |
| 168 | { | |
| 169 | DetachOpenGL(); | |
| 170 | opengl_attached = false; | |
| 171 | } | |
| 172 | ||
| 173 | DestroyWindow(window_handle); | |
| 174 | UnregisterClass(tstring_from_utf8(instance_name), instance_handle); | |
| 175 | } | |
| 176 | ||
| 177 | // Returns a platform-dependent handle to the window. | |
| 178 | void* Shell::GetWindowHandle() | |
| 179 | { | |
| 180 | return window_handle; | |
| 181 | } | |
| 182 | ||
| 183 | // Flips the OpenGL buffers. | |
| 184 | void Shell::FlipBuffers() | |
| 185 | { | |
| 186 | SwapBuffers(device_context); | |
| 187 | } | |
| 188 | ||
| 189 | void Shell::EventLoop(ShellIdleFunction idle_function) | |
| 190 | { | |
| 191 | MSG message; | |
| 192 | running = true; | |
| 193 | ||
| 194 | // Loop on PeekMessage() / GetMessage() until exit has been requested. | |
| 195 | while (running) | |
| 196 | { | |
| 197 | if (PeekMessage(&message, NULL, 0, 0, PM_NOREMOVE)) | |
| 198 | { | |
| 199 | GetMessage(&message, NULL, 0, 0); | |
| 200 | ||
| 201 | TranslateMessage(&message); | |
| 202 | DispatchMessage(&message); | |
| 203 | } | |
| 204 | ||
| 205 | idle_function(); | |
| 206 | ||
| 207 | if (!activated) | |
| 208 | Sleep(100); | |
| 209 | } | |
| 210 | } | |
| 211 | ||
| 212 | void Shell::RequestExit() | |
| 213 | { | |
| 214 | running = false; | |
| 215 | } | |
| 216 | ||
| 217 | void Shell::DisplayError(const char* fmt, ...) | |
| 218 | { | |
| 219 | const int buffer_size = 1024; | |
| 220 | char buffer[buffer_size]; | |
| 221 | va_list argument_list; | |
| 222 | ||
| 223 | // Print the message to the buffer. | |
| 224 | va_start(argument_list, fmt); | |
| 225 | int len = vsnprintf(buffer, buffer_size - 2, fmt, argument_list); | |
| 226 | if ( len < 0 || len > buffer_size - 2 ) | |
| 227 | { | |
| 228 | len = buffer_size - 2; | |
| 229 | } | |
| 230 | buffer[len] = '\n'; | |
| 231 | buffer[len + 1] = '\0'; | |
| 232 | va_end(argument_list); | |
| 233 | ||
| 234 | MessageBox(window_handle, tstring_from_utf8(buffer), TEXT("Shell Error"), MB_OK); | |
| 235 | } | |
| 236 | ||
| 237 | void Shell::Log(const char* fmt, ...) | |
| 238 | { | |
| 239 | const int buffer_size = 1024; | |
| 240 | char buffer[buffer_size]; | |
| 241 | va_list argument_list; | |
| 242 | ||
| 243 | // Print the message to the buffer. | |
| 244 | va_start(argument_list, fmt); | |
| 245 | int len = vsnprintf(buffer, buffer_size - 2, fmt, argument_list); | |
| 246 | if ( len < 0 || len > buffer_size - 2 ) | |
| 247 | { | |
| 248 | len = buffer_size - 2; | |
| 249 | } | |
| 250 | buffer[len] = '\n'; | |
| 251 | buffer[len + 1] = '\0'; | |
| 252 | va_end(argument_list); | |
| 253 | ||
| 254 | OutputDebugString(tstring_from_utf8(buffer)); | |
| 255 | } | |
| 256 | ||
| 257 | float Shell::GetElapsedTime() | |
| 258 | { | |
| 259 | LARGE_INTEGER counter; | |
| 260 | QueryPerformanceCounter(&counter); | |
| 261 | ||
| 262 | return (float)((counter.QuadPart - time_startup.QuadPart) * time_frequency); | |
| 263 | } | |
| 264 | ||
| 265 | static bool AttachOpenGL() | |
| 266 | { | |
| 267 | device_context = GetDC(window_handle); | |
| 268 | if (device_context == NULL) | |
| 269 | { | |
| 270 | Shell::DisplayError("Could not get device context."); | |
| 271 | return false; | |
| 272 | } | |
| 273 | ||
| 274 | PIXELFORMATDESCRIPTOR pixel_format_descriptor; | |
| 275 | memset(&pixel_format_descriptor, 0, sizeof(pixel_format_descriptor)); | |
| 276 | pixel_format_descriptor.nSize = sizeof(PIXELFORMATDESCRIPTOR); | |
| 277 | pixel_format_descriptor.nVersion = 1; | |
| 278 | pixel_format_descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; | |
| 279 | pixel_format_descriptor.iPixelType = PFD_TYPE_RGBA; | |
| 280 | pixel_format_descriptor.cColorBits = 32; | |
| 281 | pixel_format_descriptor.cRedBits = 8; | |
| 282 | pixel_format_descriptor.cGreenBits = 8; | |
| 283 | pixel_format_descriptor.cBlueBits = 8; | |
| 284 | pixel_format_descriptor.cAlphaBits = 8; | |
| 285 | pixel_format_descriptor.cDepthBits = 24; | |
| 286 | pixel_format_descriptor.cStencilBits = 8; | |
| 287 | ||
| 288 | int pixel_format = ChoosePixelFormat(device_context, &pixel_format_descriptor); | |
| 289 | if (pixel_format == 0) | |
| 290 | { | |
| 291 | Shell::DisplayError("Could not choose 32-bit pixel format."); | |
| 292 | return false; | |
| 293 | } | |
| 294 | ||
| 295 | if (SetPixelFormat(device_context, pixel_format, &pixel_format_descriptor) == FALSE) | |
| 296 | { | |
| 297 | Shell::DisplayError("Could not set pixel format."); | |
| 298 | return false; | |
| 299 | } | |
| 300 | ||
| 301 | render_context = wglCreateContext(device_context); | |
| 302 | if (render_context == NULL) | |
| 303 | { | |
| 304 | Shell::DisplayError("Could not create OpenGL rendering context."); | |
| 305 | return false; | |
| 306 | } | |
| 307 | ||
| 308 | // Activate the rendering context. | |
| 309 | if (wglMakeCurrent(device_context, render_context) == FALSE) | |
| 310 | { | |
| 311 | Shell::DisplayError("Unable to make rendering context current."); | |
| 312 | return false; | |
| 313 | } | |
| 314 | ||
| 315 | // Set up the GL state. | |
| 316 | glClearColor(0, 0, 0, 1); | |
| 317 | glEnableClientState(GL_VERTEX_ARRAY); | |
| 318 | glEnableClientState(GL_COLOR_ARRAY); | |
| 319 | ||
| 320 | glEnable(GL_BLEND); | |
| 321 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
| 322 | ||
| 323 | glMatrixMode(GL_PROJECTION); | |
| 324 | glLoadIdentity(); | |
| 325 | glOrtho(0, 1024, 768, 0, -1, 1); | |
| 326 | ||
| 327 | glMatrixMode(GL_MODELVIEW); | |
| 328 | glLoadIdentity(); | |
| 329 | ||
| 330 | return true; | |
| 331 | } | |
| 332 | ||
| 333 | static void DetachOpenGL() | |
| 334 | { | |
| 335 | if (render_context != NULL) | |
| 336 | { | |
| 337 | wglMakeCurrent(NULL, NULL); | |
| 338 | wglDeleteContext(render_context); | |
| 339 | render_context = NULL; | |
| 340 | } | |
| 341 | ||
| 342 | if (device_context != NULL) | |
| 343 | { | |
| 344 | ReleaseDC(window_handle, device_context); | |
| 345 | device_context = NULL; | |
| 346 | } | |
| 347 | } | |
| 348 | ||
| 349 | static LRESULT CALLBACK WindowProcedure(HWND window_handle, UINT message, WPARAM w_param, LPARAM l_param) | |
| 350 | { | |
| 351 | // See what kind of message we've got. | |
| 352 | switch (message) | |
| 353 | { | |
| 354 | case WM_ACTIVATE: | |
| 355 | { | |
| 356 | if (LOWORD(w_param) != WA_INACTIVE) | |
| 357 | { | |
| 358 | activated = true; | |
| 359 | } | |
| 360 | else | |
| 361 | { | |
| 362 | activated = false; | |
| 363 | } | |
| 364 | } | |
| 365 | break; | |
| 366 | ||
| 367 | // When the window closes, request exit | |
| 368 | case WM_CLOSE: | |
| 369 | { | |
| 370 | running = false; | |
| 371 | return 0; | |
| 372 | } | |
| 373 | break; | |
| 374 | ||
| 375 | default: | |
| 376 | { | |
| 377 | InputWin32::ProcessWindowsEvent(message, w_param, l_param); | |
| 378 | } | |
| 379 | break; | |
| 380 | } | |
| 381 | ||
| 382 | // All unhandled messages go to DefWindowProc. | |
| 383 | return DefWindowProc(window_handle, message, w_param, l_param); | |
| 384 | } |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <Rocket/Core.h> | |
| 29 | #include <Rocket/Debugger.h> | |
| 30 | #include <RocketInput.h> | |
| 31 | #include <Shell.h> | |
| 32 | ||
| 33 | Rocket::Core::Context* context = NULL; | |
| 34 | ||
| 35 | void GameLoop() | |
| 36 | { | |
| 37 | glClear(GL_COLOR_BUFFER_BIT); | |
| 38 | ||
| 39 | context->Update(); | |
| 40 | context->Render(); | |
| 41 | ||
| 42 | Shell::FlipBuffers(); | |
| 43 | } | |
| 44 | ||
| 45 | int main(int ROCKET_UNUSED(argc), char** ROCKET_UNUSED(argv)) | |
| 46 | { | |
| 47 | // Generic OS initialisation, creates a window and does not attach OpenGL. | |
| 48 | if (!Shell::Initialise("test/") || | |
| 49 | !Shell::OpenWindow("MAME Sample", true )) //false if directx | |
| 50 | { | |
| 51 | Shell::Shutdown(); | |
| 52 | return -1; | |
| 53 | } | |
| 54 | ||
| 55 | // Rocket initialisation. | |
| 56 | ShellRenderInterfaceOpenGL opengl_renderer; | |
| 57 | Rocket::Core::SetRenderInterface(&opengl_renderer); | |
| 58 | ||
| 59 | ShellSystemInterface system_interface; | |
| 60 | Rocket::Core::SetSystemInterface(&system_interface); | |
| 61 | ||
| 62 | Rocket::Core::Initialise(); | |
| 63 | ||
| 64 | // Create the main Rocket context and set it on the shell's input layer. | |
| 65 | context = Rocket::Core::CreateContext("main", Rocket::Core::Vector2i(1024, 768)); | |
| 66 | if (context == NULL) | |
| 67 | { | |
| 68 | Rocket::Core::Shutdown(); | |
| 69 | Shell::Shutdown(); | |
| 70 | return -1; | |
| 71 | } | |
| 72 | ||
| 73 | Rocket::Debugger::Initialise(context); | |
| 74 | Input::SetContext(context); | |
| 75 | ||
| 76 | Shell::LoadFonts("test/"); | |
| 77 | ||
| 78 | // Load and show the tutorial document. | |
| 79 | Rocket::Core::ElementDocument* document = context->LoadDocument("test/demo.rml"); | |
| 80 | if (document != NULL) | |
| 81 | { | |
| 82 | document->Show(); | |
| 83 | document->RemoveReference(); | |
| 84 | } | |
| 85 | ||
| 86 | Shell::EventLoop(GameLoop); | |
| 87 | ||
| 88 | // Shutdown Rocket. | |
| 89 | context->RemoveReference(); | |
| 90 | Rocket::Core::Shutdown(); | |
| 91 | ||
| 92 | //ShutdownDirectX(); | |
| 93 | ||
| 94 | Shell::CloseWindow(); | |
| 95 | Shell::Shutdown(); | |
| 96 | ||
| 97 | return 0; | |
| 98 | } |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r23952 | r23953 | |
|---|---|---|
| 43 | 43 | |
| 44 | 44 | OBJDIRS += \ |
| 45 | 45 | $(TOOLSOBJ) \ |
| 46 | $(TOOLSOBJ)/win32 \ | |
| 46 | 47 | |
| 47 | 48 | |
| 48 | 49 | |
| r23952 | r23953 | |
| 61 | 62 | srcclean$(EXE) \ |
| 62 | 63 | src2html$(EXE) \ |
| 63 | 64 | split$(EXE) \ |
| 65 | rocket$(EXE) \ | |
| 64 | 66 | |
| 65 | 67 | |
| 66 | 68 | |
| r23952 | r23953 | |
| 192 | 194 | split$(EXE): $(SPLITOBJS) $(LIBUTIL) $(LIBOCORE) $(ZLIB) $(EXPAT) |
| 193 | 195 | @echo Linking $@... |
| 194 | 196 | $(LD) $(LDFLAGS) $^ $(LIBS) -o $@ |
| 197 | ||
| 198 | #------------------------------------------------- | |
| 199 | # rocket | |
| 200 | #------------------------------------------------- | |
| 201 | ||
| 202 | ROCKETTOOLOBJS = \ | |
| 203 | $(TOOLSOBJ)/main.o \ | |
| 204 | $(TOOLSOBJ)/Shell.o \ | |
| 205 | $(TOOLSOBJ)/RocketInput.o \ | |
| 206 | $(TOOLSOBJ)/ShellFileInterface.o \ | |
| 207 | $(TOOLSOBJ)/ShellRenderInterfaceOpenGL.o \ | |
| 208 | $(TOOLSOBJ)/ShellSystemInterface.o \ | |
| 209 | $(TOOLSOBJ)/ShellSystemInterface.o \ | |
| 210 | $(TOOLSOBJ)/win32/InputWin32.o \ | |
| 211 | $(TOOLSOBJ)/win32/ShellWin32.o \ | |
| 212 | ||
| 213 | rocket$(EXE): $(ROCKETTOOLOBJS) $(ROCKET_LIB) $(LIBUTIL) $(LIBOCORE) $(ZLIB) $(EXPAT) | |
| 214 | @echo Linking $@... | |
| 215 | $(LD) $(LDFLAGS) $^ $(LIBS) -lfreetype -lopengl32 -o $@ | |
| 216 | ||
| 217 | $(TOOLSOBJ)/%.o: $(TOOLSSRC)/%.cpp | $(OSPREBUILD) | |
| 218 | @echo Compiling $<... | |
| 219 | $(CC) $(CDEFS) $(CFLAGS) -c -I$(TOOLSSRC) -I$(LIBSRC)/librocket/Include -DSTATIC_LIB $< -o $@ | |
| 220 |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <ShellFileInterface.h> | |
| 29 | #include <stdio.h> | |
| 30 | ||
| 31 | ShellFileInterface::ShellFileInterface(const Rocket::Core::String& root) : root(root) | |
| 32 | { | |
| 33 | } | |
| 34 | ||
| 35 | ShellFileInterface::~ShellFileInterface() | |
| 36 | { | |
| 37 | } | |
| 38 | ||
| 39 | // Opens a file. | |
| 40 | Rocket::Core::FileHandle ShellFileInterface::Open(const Rocket::Core::String& path) | |
| 41 | { | |
| 42 | // Attempt to open the file relative to the application's root. | |
| 43 | FILE* fp = fopen((root + path).CString(), "rb"); | |
| 44 | if (fp != NULL) | |
| 45 | return (Rocket::Core::FileHandle) fp; | |
| 46 | ||
| 47 | // Attempt to open the file relative to the current working directory. | |
| 48 | fp = fopen(path.CString(), "rb"); | |
| 49 | return (Rocket::Core::FileHandle) fp; | |
| 50 | } | |
| 51 | ||
| 52 | // Closes a previously opened file. | |
| 53 | void ShellFileInterface::Close(Rocket::Core::FileHandle file) | |
| 54 | { | |
| 55 | fclose((FILE*) file); | |
| 56 | } | |
| 57 | ||
| 58 | // Reads data from a previously opened file. | |
| 59 | size_t ShellFileInterface::Read(void* buffer, size_t size, Rocket::Core::FileHandle file) | |
| 60 | { | |
| 61 | return fread(buffer, 1, size, (FILE*) file); | |
| 62 | } | |
| 63 | ||
| 64 | // Seeks to a point in a previously opened file. | |
| 65 | bool ShellFileInterface::Seek(Rocket::Core::FileHandle file, long offset, int origin) | |
| 66 | { | |
| 67 | return fseek((FILE*) file, offset, origin) == 0; | |
| 68 | } | |
| 69 | ||
| 70 | // Returns the current position of the file pointer. | |
| 71 | size_t ShellFileInterface::Tell(Rocket::Core::FileHandle file) | |
| 72 | { | |
| 73 | return ftell((FILE*) file); | |
| 74 | } |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <ShellSystemInterface.h> | |
| 29 | #include <Shell.h> | |
| 30 | ||
| 31 | // Get the number of seconds elapsed since the start of the application | |
| 32 | float ShellSystemInterface::GetElapsedTime() | |
| 33 | { | |
| 34 | return Shell::GetElapsedTime(); | |
| 35 | } |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <ShellRenderInterfaceOpenGL.h> | |
| 29 | #include <Rocket/Core.h> | |
| 30 | ||
| 31 | #define GL_CLAMP_TO_EDGE 0x812F | |
| 32 | ||
| 33 | ShellRenderInterfaceOpenGL::ShellRenderInterfaceOpenGL() | |
| 34 | { | |
| 35 | } | |
| 36 | ||
| 37 | // Called by Rocket when it wants to render geometry that it does not wish to optimise. | |
| 38 | void ShellRenderInterfaceOpenGL::RenderGeometry(Rocket::Core::Vertex* vertices, int ROCKET_UNUSED(num_vertices), int* indices, int num_indices, const Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation) | |
| 39 | { | |
| 40 | glPushMatrix(); | |
| 41 | glTranslatef(translation.x, translation.y, 0); | |
| 42 | ||
| 43 | glVertexPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].position); | |
| 44 | glEnableClientState(GL_COLOR_ARRAY); | |
| 45 | glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Rocket::Core::Vertex), &vertices[0].colour); | |
| 46 | ||
| 47 | if (!texture) | |
| 48 | { | |
| 49 | glDisable(GL_TEXTURE_2D); | |
| 50 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |
| 51 | } | |
| 52 | else | |
| 53 | { | |
| 54 | glEnable(GL_TEXTURE_2D); | |
| 55 | glBindTexture(GL_TEXTURE_2D, (GLuint) texture); | |
| 56 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); | |
| 57 | glTexCoordPointer(2, GL_FLOAT, sizeof(Rocket::Core::Vertex), &vertices[0].tex_coord); | |
| 58 | } | |
| 59 | ||
| 60 | glDrawElements(GL_TRIANGLES, num_indices, GL_UNSIGNED_INT, indices); | |
| 61 | ||
| 62 | glPopMatrix(); | |
| 63 | } | |
| 64 | ||
| 65 | // Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future. | |
| 66 | Rocket::Core::CompiledGeometryHandle ShellRenderInterfaceOpenGL::CompileGeometry(Rocket::Core::Vertex* ROCKET_UNUSED(vertices), int ROCKET_UNUSED(num_vertices), int* ROCKET_UNUSED(indices), int ROCKET_UNUSED(num_indices), const Rocket::Core::TextureHandle ROCKET_UNUSED(texture)) | |
| 67 | { | |
| 68 | return (Rocket::Core::CompiledGeometryHandle) NULL; | |
| 69 | } | |
| 70 | ||
| 71 | // Called by Rocket when it wants to render application-compiled geometry. | |
| 72 | void ShellRenderInterfaceOpenGL::RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle ROCKET_UNUSED(geometry), const Rocket::Core::Vector2f& ROCKET_UNUSED(translation)) | |
| 73 | { | |
| 74 | } | |
| 75 | ||
| 76 | // Called by Rocket when it wants to release application-compiled geometry. | |
| 77 | void ShellRenderInterfaceOpenGL::ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle ROCKET_UNUSED(geometry)) | |
| 78 | { | |
| 79 | } | |
| 80 | ||
| 81 | // Called by Rocket when it wants to enable or disable scissoring to clip content. | |
| 82 | void ShellRenderInterfaceOpenGL::EnableScissorRegion(bool enable) | |
| 83 | { | |
| 84 | if (enable) | |
| 85 | glEnable(GL_SCISSOR_TEST); | |
| 86 | else | |
| 87 | glDisable(GL_SCISSOR_TEST); | |
| 88 | } | |
| 89 | ||
| 90 | // Called by Rocket when it wants to change the scissor region. | |
| 91 | void ShellRenderInterfaceOpenGL::SetScissorRegion(int x, int y, int width, int height) | |
| 92 | { | |
| 93 | glScissor(x, 768 - (y + height), width, height); | |
| 94 | } | |
| 95 | ||
| 96 | // Set to byte packing, or the compiler will expand our struct, which means it won't read correctly from file | |
| 97 | #pragma pack(1) | |
| 98 | struct TGAHeader | |
| 99 | { | |
| 100 | char idLength; | |
| 101 | char colourMapType; | |
| 102 | char dataType; | |
| 103 | short int colourMapOrigin; | |
| 104 | short int colourMapLength; | |
| 105 | char colourMapDepth; | |
| 106 | short int xOrigin; | |
| 107 | short int yOrigin; | |
| 108 | short int width; | |
| 109 | short int height; | |
| 110 | char bitsPerPixel; | |
| 111 | char imageDescriptor; | |
| 112 | }; | |
| 113 | // Restore packing | |
| 114 | #pragma pack() | |
| 115 | ||
| 116 | // Called by Rocket when a texture is required by the library. | |
| 117 | bool ShellRenderInterfaceOpenGL::LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source) | |
| 118 | { | |
| 119 | Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface(); | |
| 120 | Rocket::Core::FileHandle file_handle = file_interface->Open(source); | |
| 121 | if (!file_handle) | |
| 122 | { | |
| 123 | return false; | |
| 124 | } | |
| 125 | ||
| 126 | file_interface->Seek(file_handle, 0, SEEK_END); | |
| 127 | size_t buffer_size = file_interface->Tell(file_handle); | |
| 128 | file_interface->Seek(file_handle, 0, SEEK_SET); | |
| 129 | ||
| 130 | char* buffer = new char[buffer_size]; | |
| 131 | file_interface->Read(buffer, buffer_size, file_handle); | |
| 132 | file_interface->Close(file_handle); | |
| 133 | ||
| 134 | TGAHeader header; | |
| 135 | memcpy(&header, buffer, sizeof(TGAHeader)); | |
| 136 | ||
| 137 | int color_mode = header.bitsPerPixel / 8; | |
| 138 | int image_size = header.width * header.height * 4; // We always make 32bit textures | |
| 139 | ||
| 140 | if (header.dataType != 2) | |
| 141 | { | |
| 142 | Rocket::Core::Log::Message(Rocket::Core::Log::LT_ERROR, "Only 24/32bit uncompressed TGAs are supported."); | |
| 143 | return false; | |
| 144 | } | |
| 145 | ||
| 146 | // Ensure we have at least 3 colors | |
| 147 | if (color_mode < 3) | |
| 148 | { | |
| 149 | Rocket::Core::Log::Message(Rocket::Core::Log::LT_ERROR, "Only 24 and 32bit textures are supported"); | |
| 150 | return false; | |
| 151 | } | |
| 152 | ||
| 153 | const char* image_src = buffer + sizeof(TGAHeader); | |
| 154 | unsigned char* image_dest = new unsigned char[image_size]; | |
| 155 | ||
| 156 | // Targa is BGR, swap to RGB and flip Y axis | |
| 157 | for (long y = 0; y < header.height; y++) | |
| 158 | { | |
| 159 | long read_index = y * header.width * color_mode; | |
| 160 | long write_index = ((header.imageDescriptor & 32) != 0) ? read_index : (header.height - y - 1) * header.width * color_mode; | |
| 161 | for (long x = 0; x < header.width; x++) | |
| 162 | { | |
| 163 | image_dest[write_index] = image_src[read_index+2]; | |
| 164 | image_dest[write_index+1] = image_src[read_index+1]; | |
| 165 | image_dest[write_index+2] = image_src[read_index]; | |
| 166 | if (color_mode == 4) | |
| 167 | image_dest[write_index+3] = image_src[read_index+3]; | |
| 168 | else | |
| 169 | image_dest[write_index+3] = 255; | |
| 170 | ||
| 171 | write_index += 4; | |
| 172 | read_index += color_mode; | |
| 173 | } | |
| 174 | } | |
| 175 | ||
| 176 | texture_dimensions.x = header.width; | |
| 177 | texture_dimensions.y = header.height; | |
| 178 | ||
| 179 | bool success = GenerateTexture(texture_handle, image_dest, texture_dimensions); | |
| 180 | ||
| 181 | delete [] image_dest; | |
| 182 | delete [] buffer; | |
| 183 | ||
| 184 | return success; | |
| 185 | } | |
| 186 | ||
| 187 | // Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels. | |
| 188 | bool ShellRenderInterfaceOpenGL::GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions) | |
| 189 | { | |
| 190 | GLuint texture_id = 0; | |
| 191 | glGenTextures(1, &texture_id); | |
| 192 | if (texture_id == 0) | |
| 193 | { | |
| 194 | printf("Failed to generate textures\n"); | |
| 195 | return false; | |
| 196 | } | |
| 197 | ||
| 198 | glBindTexture(GL_TEXTURE_2D, texture_id); | |
| 199 | ||
| 200 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, source_dimensions.x, source_dimensions.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, source); | |
| 201 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
| 202 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
| 203 | ||
| 204 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | |
| 205 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | |
| 206 | ||
| 207 | texture_handle = (Rocket::Core::TextureHandle) texture_id; | |
| 208 | ||
| 209 | return true; | |
| 210 | } | |
| 211 | ||
| 212 | // Called by Rocket when a loaded texture is no longer required. | |
| 213 | void ShellRenderInterfaceOpenGL::ReleaseTexture(Rocket::Core::TextureHandle texture_handle) | |
| 214 | { | |
| 215 | glDeleteTextures(1, (GLuint*) &texture_handle); | |
| 216 | } | |
| 217 |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef SHELLFILEINTERFACE_H | |
| 29 | #define SHELLFILEINTERFACE_H | |
| 30 | ||
| 31 | #include <Rocket/Core/String.h> | |
| 32 | #include <Rocket/Core/FileInterface.h> | |
| 33 | ||
| 34 | /** | |
| 35 | Rocket file interface for the shell examples. | |
| 36 | @author Lloyd Weehuizen | |
| 37 | */ | |
| 38 | ||
| 39 | class ShellFileInterface : public Rocket::Core::FileInterface | |
| 40 | { | |
| 41 | public: | |
| 42 | ShellFileInterface(const Rocket::Core::String& root); | |
| 43 | virtual ~ShellFileInterface(); | |
| 44 | ||
| 45 | /// Opens a file. | |
| 46 | virtual Rocket::Core::FileHandle Open(const Rocket::Core::String& path); | |
| 47 | ||
| 48 | /// Closes a previously opened file. | |
| 49 | virtual void Close(Rocket::Core::FileHandle file); | |
| 50 | ||
| 51 | /// Reads data from a previously opened file. | |
| 52 | virtual size_t Read(void* buffer, size_t size, Rocket::Core::FileHandle file); | |
| 53 | ||
| 54 | /// Seeks to a point in a previously opened file. | |
| 55 | virtual bool Seek(Rocket::Core::FileHandle file, long offset, int origin); | |
| 56 | ||
| 57 | /// Returns the current position of the file pointer. | |
| 58 | virtual size_t Tell(Rocket::Core::FileHandle file); | |
| 59 | ||
| 60 | private: | |
| 61 | Rocket::Core::String root; | |
| 62 | }; | |
| 63 | ||
| 64 | #endif |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef ROCKETSHELLSYSTEMINTERFACE_H | |
| 29 | #define ROCKETSHELLSYSTEMINTERFACE_H | |
| 30 | ||
| 31 | #include <Rocket/Core/SystemInterface.h> | |
| 32 | ||
| 33 | /** | |
| 34 | A custom system interface for Rocket. This provides timing information. | |
| 35 | @author Lloyd Weehuizen | |
| 36 | */ | |
| 37 | ||
| 38 | class ShellSystemInterface : public Rocket::Core::SystemInterface | |
| 39 | { | |
| 40 | public: | |
| 41 | /// Get the number of seconds elapsed since the start of the application | |
| 42 | /// @returns Seconds elapsed | |
| 43 | virtual float GetElapsedTime(); | |
| 44 | }; | |
| 45 | ||
| 46 | #endif |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef ROCKETSHELLRENDERINTERFACE_H | |
| 29 | #define ROCKETSHELLRENDERINTERFACE_H | |
| 30 | ||
| 31 | #include "Rocket/Core/RenderInterface.h" | |
| 32 | #include "ShellOpenGL.h" | |
| 33 | ||
| 34 | /** | |
| 35 | Low level OpenGL render interface for Rocket | |
| 36 | @author Peter Curry | |
| 37 | */ | |
| 38 | ||
| 39 | class ShellRenderInterfaceOpenGL : public Rocket::Core::RenderInterface | |
| 40 | { | |
| 41 | public: | |
| 42 | ShellRenderInterfaceOpenGL(); | |
| 43 | ||
| 44 | /// Called by Rocket when it wants to render geometry that it does not wish to optimise. | |
| 45 | virtual void RenderGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture, const Rocket::Core::Vector2f& translation); | |
| 46 | ||
| 47 | /// Called by Rocket when it wants to compile geometry it believes will be static for the forseeable future. | |
| 48 | virtual Rocket::Core::CompiledGeometryHandle CompileGeometry(Rocket::Core::Vertex* vertices, int num_vertices, int* indices, int num_indices, Rocket::Core::TextureHandle texture); | |
| 49 | ||
| 50 | /// Called by Rocket when it wants to render application-compiled geometry. | |
| 51 | virtual void RenderCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry, const Rocket::Core::Vector2f& translation); | |
| 52 | /// Called by Rocket when it wants to release application-compiled geometry. | |
| 53 | virtual void ReleaseCompiledGeometry(Rocket::Core::CompiledGeometryHandle geometry); | |
| 54 | ||
| 55 | /// Called by Rocket when it wants to enable or disable scissoring to clip content. | |
| 56 | virtual void EnableScissorRegion(bool enable); | |
| 57 | /// Called by Rocket when it wants to change the scissor region. | |
| 58 | virtual void SetScissorRegion(int x, int y, int width, int height); | |
| 59 | ||
| 60 | /// Called by Rocket when a texture is required by the library. | |
| 61 | virtual bool LoadTexture(Rocket::Core::TextureHandle& texture_handle, Rocket::Core::Vector2i& texture_dimensions, const Rocket::Core::String& source); | |
| 62 | /// Called by Rocket when a texture is required to be built from an internally-generated sequence of pixels. | |
| 63 | virtual bool GenerateTexture(Rocket::Core::TextureHandle& texture_handle, const Rocket::Core::byte* source, const Rocket::Core::Vector2i& source_dimensions); | |
| 64 | /// Called by Rocket when a loaded texture is no longer required. | |
| 65 | virtual void ReleaseTexture(Rocket::Core::TextureHandle texture_handle); | |
| 66 | }; | |
| 67 | ||
| 68 | #endif |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include "Shell.h" | |
| 29 | #include <Rocket/Core/FontDatabase.h> | |
| 30 | ||
| 31 | Rocket::Core::String Shell::executable_path; | |
| 32 | ||
| 33 | /// Loads the default fonts from the given path. | |
| 34 | void Shell::LoadFonts(const char* directory) | |
| 35 | { | |
| 36 | Rocket::Core::String font_names[4]; | |
| 37 | font_names[0] = "Delicious-Roman.otf"; | |
| 38 | font_names[1] = "Delicious-Italic.otf"; | |
| 39 | font_names[2] = "Delicious-Bold.otf"; | |
| 40 | font_names[3] = "Delicious-BoldItalic.otf"; | |
| 41 | ||
| 42 | for (int i = 0; i < sizeof(font_names) / sizeof(Rocket::Core::String); i++) | |
| 43 | { | |
| 44 | Rocket::Core::FontDatabase::LoadFontFace(Rocket::Core::String(directory) + font_names[i]); | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| 48 | // Returns the path to the application's executable. | |
| 49 | const Rocket::Core::String& Shell::GetExecutablePath() | |
| 50 | { | |
| 51 | return executable_path; | |
| 52 | } | |
| 53 |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #include <RocketInput.h> | |
| 29 | ||
| 30 | /** | |
| 31 | This map contains 4 different mappings from key identifiers to character codes. Each entry represents a different | |
| 32 | combination of shift and capslock state. | |
| 33 | */ | |
| 34 | ||
| 35 | char ascii_map[4][51] = | |
| 36 | { | |
| 37 | // shift off and capslock off | |
| 38 | { | |
| 39 | 0, | |
| 40 | ' ', | |
| 41 | '0', | |
| 42 | '1', | |
| 43 | '2', | |
| 44 | '3', | |
| 45 | '4', | |
| 46 | '5', | |
| 47 | '6', | |
| 48 | '7', | |
| 49 | '8', | |
| 50 | '9', | |
| 51 | 'a', | |
| 52 | 'b', | |
| 53 | 'c', | |
| 54 | 'd', | |
| 55 | 'e', | |
| 56 | 'f', | |
| 57 | 'g', | |
| 58 | 'h', | |
| 59 | 'i', | |
| 60 | 'j', | |
| 61 | 'k', | |
| 62 | 'l', | |
| 63 | 'm', | |
| 64 | 'n', | |
| 65 | 'o', | |
| 66 | 'p', | |
| 67 | 'q', | |
| 68 | 'r', | |
| 69 | 's', | |
| 70 | 't', | |
| 71 | 'u', | |
| 72 | 'v', | |
| 73 | 'w', | |
| 74 | 'x', | |
| 75 | 'y', | |
| 76 | 'z', | |
| 77 | ';', | |
| 78 | '=', | |
| 79 | ',', | |
| 80 | '-', | |
| 81 | '.', | |
| 82 | '/', | |
| 83 | '`', | |
| 84 | '[', | |
| 85 | '\\', | |
| 86 | ']', | |
| 87 | '\'', | |
| 88 | 0, | |
| 89 | 0 | |
| 90 | }, | |
| 91 | ||
| 92 | // shift on and capslock off | |
| 93 | { | |
| 94 | 0, | |
| 95 | ' ', | |
| 96 | ')', | |
| 97 | '!', | |
| 98 | '@', | |
| 99 | '#', | |
| 100 | '$', | |
| 101 | '%', | |
| 102 | '^', | |
| 103 | '&', | |
| 104 | '*', | |
| 105 | '(', | |
| 106 | 'A', | |
| 107 | 'B', | |
| 108 | 'C', | |
| 109 | 'D', | |
| 110 | 'E', | |
| 111 | 'F', | |
| 112 | 'G', | |
| 113 | 'H', | |
| 114 | 'I', | |
| 115 | 'J', | |
| 116 | 'K', | |
| 117 | 'L', | |
| 118 | 'M', | |
| 119 | 'N', | |
| 120 | 'O', | |
| 121 | 'P', | |
| 122 | 'Q', | |
| 123 | 'R', | |
| 124 | 'S', | |
| 125 | 'T', | |
| 126 | 'U', | |
| 127 | 'V', | |
| 128 | 'W', | |
| 129 | 'X', | |
| 130 | 'Y', | |
| 131 | 'Z', | |
| 132 | ':', | |
| 133 | '+', | |
| 134 | '<', | |
| 135 | '_', | |
| 136 | '>', | |
| 137 | '?', | |
| 138 | '~', | |
| 139 | '{', | |
| 140 | '|', | |
| 141 | '}', | |
| 142 | '"', | |
| 143 | 0, | |
| 144 | 0 | |
| 145 | }, | |
| 146 | ||
| 147 | // shift on and capslock on | |
| 148 | { | |
| 149 | 0, | |
| 150 | ' ', | |
| 151 | ')', | |
| 152 | '!', | |
| 153 | '@', | |
| 154 | '#', | |
| 155 | '$', | |
| 156 | '%', | |
| 157 | '^', | |
| 158 | '&', | |
| 159 | '*', | |
| 160 | '(', | |
| 161 | 'a', | |
| 162 | 'b', | |
| 163 | 'c', | |
| 164 | 'd', | |
| 165 | 'e', | |
| 166 | 'f', | |
| 167 | 'g', | |
| 168 | 'h', | |
| 169 | 'i', | |
| 170 | 'j', | |
| 171 | 'k', | |
| 172 | 'l', | |
| 173 | 'm', | |
| 174 | 'n', | |
| 175 | 'o', | |
| 176 | 'p', | |
| 177 | 'q', | |
| 178 | 'r', | |
| 179 | 's', | |
| 180 | 't', | |
| 181 | 'u', | |
| 182 | 'v', | |
| 183 | 'w', | |
| 184 | 'x', | |
| 185 | 'y', | |
| 186 | 'z', | |
| 187 | ':', | |
| 188 | '+', | |
| 189 | '<', | |
| 190 | '_', | |
| 191 | '>', | |
| 192 | '?', | |
| 193 | '~', | |
| 194 | '{', | |
| 195 | '|', | |
| 196 | '}', | |
| 197 | '"', | |
| 198 | 0, | |
| 199 | 0 | |
| 200 | }, | |
| 201 | ||
| 202 | // shift off and capslock on | |
| 203 | { | |
| 204 | 0, | |
| 205 | ' ', | |
| 206 | '1', | |
| 207 | '2', | |
| 208 | '3', | |
| 209 | '4', | |
| 210 | '5', | |
| 211 | '6', | |
| 212 | '7', | |
| 213 | '8', | |
| 214 | '9', | |
| 215 | '0', | |
| 216 | 'A', | |
| 217 | 'B', | |
| 218 | 'C', | |
| 219 | 'D', | |
| 220 | 'E', | |
| 221 | 'F', | |
| 222 | 'G', | |
| 223 | 'H', | |
| 224 | 'I', | |
| 225 | 'J', | |
| 226 | 'K', | |
| 227 | 'L', | |
| 228 | 'M', | |
| 229 | 'N', | |
| 230 | 'O', | |
| 231 | 'P', | |
| 232 | 'Q', | |
| 233 | 'R', | |
| 234 | 'S', | |
| 235 | 'T', | |
| 236 | 'U', | |
| 237 | 'V', | |
| 238 | 'W', | |
| 239 | 'X', | |
| 240 | 'Y', | |
| 241 | 'Z', | |
| 242 | ';', | |
| 243 | '=', | |
| 244 | ',', | |
| 245 | '-', | |
| 246 | '.', | |
| 247 | '/', | |
| 248 | '`', | |
| 249 | '[', | |
| 250 | '\\', | |
| 251 | ']', | |
| 252 | '\'', | |
| 253 | 0, | |
| 254 | 0 | |
| 255 | } | |
| 256 | }; | |
| 257 | ||
| 258 | char keypad_map[2][18] = | |
| 259 | { | |
| 260 | { | |
| 261 | '0', | |
| 262 | '1', | |
| 263 | '2', | |
| 264 | '3', | |
| 265 | '4', | |
| 266 | '5', | |
| 267 | '6', | |
| 268 | '7', | |
| 269 | '8', | |
| 270 | '9', | |
| 271 | '\n', | |
| 272 | '*', | |
| 273 | '+', | |
| 274 | 0, | |
| 275 | '-', | |
| 276 | '.', | |
| 277 | '/', | |
| 278 | '=' | |
| 279 | }, | |
| 280 | ||
| 281 | { | |
| 282 | 0, | |
| 283 | 0, | |
| 284 | 0, | |
| 285 | 0, | |
| 286 | 0, | |
| 287 | 0, | |
| 288 | 0, | |
| 289 | 0, | |
| 290 | 0, | |
| 291 | 0, | |
| 292 | '\n', | |
| 293 | '*', | |
| 294 | '+', | |
| 295 | 0, | |
| 296 | '-', | |
| 297 | 0, | |
| 298 | '/', | |
| 299 | '=' | |
| 300 | } | |
| 301 | }; | |
| 302 | ||
| 303 | ||
| 304 | ||
| 305 | Rocket::Core::Context* Input::context = NULL; | |
| 306 | ||
| 307 | ||
| 308 | ||
| 309 | // Sets the context to send input events to. | |
| 310 | void Input::SetContext(Rocket::Core::Context* _context) | |
| 311 | { | |
| 312 | context = _context; | |
| 313 | } | |
| 314 | ||
| 315 | ||
| 316 | ||
| 317 | // Returns the character code for a key identifer / key modifier combination. | |
| 318 | Rocket::Core::word Input::GetCharacterCode(Rocket::Core::Input::KeyIdentifier key_identifier, int key_modifier_state) | |
| 319 | { | |
| 320 | // Check if we have a keycode capable of generating characters on the main keyboard (ie, not on the numeric | |
| 321 | // keypad; that is dealt with below). | |
| 322 | if (key_identifier <= Rocket::Core::Input::KI_OEM_102) | |
| 323 | { | |
| 324 | // Get modifier states | |
| 325 | bool shift = (key_modifier_state & Rocket::Core::Input::KM_SHIFT) > 0; | |
| 326 | bool capslock = (key_modifier_state & Rocket::Core::Input::KM_CAPSLOCK) > 0; | |
| 327 | ||
| 328 | // Return character code based on identifier and modifiers | |
| 329 | if (shift && !capslock) | |
| 330 | return ascii_map[1][key_identifier]; | |
| 331 | ||
| 332 | if (shift && capslock) | |
| 333 | return ascii_map[2][key_identifier]; | |
| 334 | ||
| 335 | if (!shift && capslock) | |
| 336 | return ascii_map[3][key_identifier]; | |
| 337 | ||
| 338 | return ascii_map[0][key_identifier]; | |
| 339 | } | |
| 340 | ||
| 341 | // Check if we have a keycode from the numeric keypad. | |
| 342 | else if (key_identifier <= Rocket::Core::Input::KI_OEM_NEC_EQUAL) | |
| 343 | { | |
| 344 | if (key_modifier_state & Rocket::Core::Input::KM_NUMLOCK) | |
| 345 | return keypad_map[0][key_identifier - Rocket::Core::Input::KI_NUMPAD0]; | |
| 346 | else | |
| 347 | return keypad_map[1][key_identifier - Rocket::Core::Input::KI_NUMPAD0]; | |
| 348 | } | |
| 349 | ||
| 350 | else if (key_identifier == Rocket::Core::Input::KI_RETURN) | |
| 351 | return '\n'; | |
| 352 | ||
| 353 | return 0; | |
| 354 | } |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef ROCKETSHELL_H | |
| 29 | #define ROCKETSHELL_H | |
| 30 | ||
| 31 | #include <Rocket/Core/Types.h> | |
| 32 | #include <Rocket/Core/SystemInterface.h> | |
| 33 | ||
| 34 | ||
| 35 | /** | |
| 36 | Shell functions for creating windows, attaching OpenGL and handling input in a platform independent way. | |
| 37 | @author Lloyd Weehuizen | |
| 38 | */ | |
| 39 | ||
| 40 | class Shell | |
| 41 | { | |
| 42 | public: | |
| 43 | /// Initialise the shell. | |
| 44 | /// @param[in] path The path (relative to the current working directory) of the application's working directory. | |
| 45 | static bool Initialise(const Rocket::Core::String& path); | |
| 46 | /// Shutdown the shell. | |
| 47 | static void Shutdown(); | |
| 48 | ||
| 49 | /// Loads the default fonts from the given path. | |
| 50 | static void LoadFonts(const char* directory); | |
| 51 | ||
| 52 | /// Returns the path to the application's executable. | |
| 53 | static const Rocket::Core::String& GetExecutablePath(); | |
| 54 | ||
| 55 | /// Open a platform specific window, optionally initialising an OpenGL context on it. | |
| 56 | /// @param[in] title Title of the window. | |
| 57 | /// @param[in] attach_opengl Attach and opengl context to the window. | |
| 58 | static bool OpenWindow(const char* title, bool attach_opengl); | |
| 59 | /// Close the active window. | |
| 60 | static void CloseWindow(); | |
| 61 | ||
| 62 | /// Returns a platform-dependent handle to the window. | |
| 63 | static void* GetWindowHandle(); | |
| 64 | ||
| 65 | /// Flips the OpenGL buffers. | |
| 66 | static void FlipBuffers(); | |
| 67 | ||
| 68 | /// Run the event loop, calling the idle function every frame. | |
| 69 | typedef void (*ShellIdleFunction)(); | |
| 70 | static void EventLoop(ShellIdleFunction idle_function); | |
| 71 | static void RequestExit(); | |
| 72 | ||
| 73 | /// Display an error message. | |
| 74 | static void DisplayError(const char* fmt, ...); | |
| 75 | /// Log a message to the debugger. | |
| 76 | static void Log(const char* fmt, ...); | |
| 77 | ||
| 78 | /// Get the number of seconds that have passed since shell startup. | |
| 79 | static float GetElapsedTime(); | |
| 80 | ||
| 81 | private: | |
| 82 | static Rocket::Core::String executable_path; | |
| 83 | }; | |
| 84 | ||
| 85 | #include "ShellRenderInterfaceOpenGL.h" | |
| 86 | #include "ShellSystemInterface.h" | |
| 87 | ||
| 88 | #endif |
| Added: svn:mime-type + text/plain Added: svn:eol-style + native |
| r0 | r23953 | |
|---|---|---|
| 1 | /* | |
| 2 | * This source file is part of libRocket, the HTML/CSS Interface Middleware | |
| 3 | * | |
| 4 | * For the latest information, see http://www.librocket.com | |
| 5 | * | |
| 6 | * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd | |
| 7 | * | |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
| 9 | * of this software and associated documentation files (the "Software"), to deal | |
| 10 | * in the Software without restriction, including without limitation the rights | |
| 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| 12 | * copies of the Software, and to permit persons to whom the Software is | |
| 13 | * furnished to do so, subject to the following conditions: | |
| 14 | * | |
| 15 | * The above copyright notice and this permission notice shall be included in | |
| 16 | * all copies or substantial portions of the Software. | |
| 17 | * | |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
| 24 | * THE SOFTWARE. | |
| 25 | * | |
| 26 | */ | |
| 27 | ||
| 28 | #ifndef SHELLINPUT_H | |
| 29 | #define SHELLINPUT_H | |
| 30 | ||
| 31 | #include <Rocket/Core/Input.h> | |
| 32 | #include <Rocket/Core/Types.h> | |
| 33 | ||
| 34 | namespace Rocket { | |
| 35 | namespace Core { | |
| 36 | ||
| 37 | class Context; | |
| 38 | ||
| 39 | } | |
| 40 | } | |
| 41 | ||
| 42 | /** | |
| 43 | */ | |
| 44 | ||
| 45 | class Input | |
| 46 | { | |
| 47 | public: | |
| 48 | /// Sets the context to send input events to. | |
| 49 | /// @param[in] context The context to send input events to. | |
| 50 | static void SetContext(Rocket::Core::Context* context); | |
| 51 | /// Returns the character code for a key identifer / key modifier combination. | |
| 52 | /// @param[in] key_identifier The key to generate a character code for. | |
| 53 | /// @param[in] key_modifier_state The configuration of the key modifiers. | |
| 54 | /// @return The character code. | |
| 55 | static Rocket::Core::word GetCharacterCode(Rocket::Core::Input::KeyIdentifier key_identifier, int key_modifier_state); | |
| 56 | ||
| 57 | protected: | |
| 58 | static Rocket::Core::Context* context; | |
| 59 | }; | |
| 60 | ||
| 61 | #endif |
| Added: svn:eol-style + native Added: svn:mime-type + text/plain |
| Previous | 199869 Revisions | Next |