├── .gitignore ├── License.pdf ├── License.txt ├── README.md ├── demo ├── COPYING ├── Hangtime2.trk ├── INSTALL ├── Midnight_madness.trk ├── QuadraPhase.trk ├── README ├── cave.h ├── caveroller ├── demo.vcproj ├── freestyle.trk ├── glbmp.c ├── glbmp.h ├── grass.tga ├── main.c ├── metal.tga ├── panneau.tga ├── parser.c ├── parser.h ├── point.c ├── point.h ├── poteau.c ├── poteau.h ├── rc2k.trk ├── roller.c ├── roller.h ├── track_format.txt └── tree.tga ├── include └── GL │ ├── gl.h │ ├── glext.h │ └── vgl.h ├── lib ├── .indent.pro ├── array.c ├── bitblt.c ├── bitmap.c ├── command.h ├── common.h ├── config.h ├── context.c ├── context.h ├── dispatch.h ├── exec.h ├── frag.c ├── fragproc.c ├── frame.c ├── frame.h ├── gl.c ├── glint.h ├── hash.c ├── hash.h ├── image.c ├── image.h ├── lib.vcproj ├── library.h ├── light.c ├── list.c ├── matrix.c ├── matrix.h ├── platform.c ├── platform.h ├── raster.c ├── raster.h ├── rasterln.c ├── rasterpg.c ├── rasterpt.c ├── render.c ├── system.h ├── tex.c ├── tex.h ├── texenv.c ├── texunit.c ├── texunit.h ├── util.c ├── util.h ├── vgl.c └── vglsdl.c └── vin_sc.sln /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | 5 | # Libraries 6 | *.lib 7 | *.a 8 | 9 | # Shared objects (inc. Windows DLLs) 10 | *.dll 11 | *.so 12 | *.so.* 13 | *.dylib 14 | 15 | # Executables 16 | *.exe 17 | *.out 18 | *.app 19 | -------------------------------------------------------------------------------- /License.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmwill/SC/cc86685ba50beded5bc88e462c4e8c1d28770b57/License.pdf -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Artistic License 2.0 2 | 3 | Copyright (c) 2000-2006, The Perl Foundation. 4 | 5 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 6 | 7 | Preamble 8 | This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. 9 | 10 | You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. 11 | 12 | Definitions 13 | "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. 14 | 15 | "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. 16 | 17 | "You" and "your" means any person who would like to copy, distribute, or modify the Package. 18 | 19 | "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. 20 | 21 | "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. 22 | 23 | "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. 24 | 25 | "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. 26 | 27 | "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. 28 | 29 | "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. 30 | 31 | "Source" form means the source code, documentation source, and configuration files for the Package. 32 | 33 | "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. 34 | 35 | Permission for Use and Modification Without Distribution 36 | (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. 37 | 38 | Permissions for Redistribution of the Standard Version 39 | (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. 40 | 41 | (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. 42 | 43 | Distribution of Modified Versions of the Package as Source 44 | (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: 45 | 46 | (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. 47 | (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. 48 | (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under 49 | (i) the Original License or 50 | (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. 51 | Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source 52 | (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. 53 | 54 | (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. 55 | 56 | Aggregating or Linking the Package 57 | (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. 58 | 59 | (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. 60 | 61 | Items That are Not Considered Part of a Modified Version 62 | (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. 63 | 64 | General Provisions 65 | (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. 66 | 67 | (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. 68 | 69 | (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. 70 | 71 | (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. 72 | 73 | (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SC 2 | == 3 | 4 | Vincent SC (OpenGL SC Software Renderer) 5 | -------------------------------------------------------------------------------- /demo/Hangtime2.trk: -------------------------------------------------------------------------------- 1 | # Hangtime (Version 2), made by Ken Ives 2 | 3 | Track 4 | 56 5 | 0 0 0.21; 0 1 0 6 | 0 4 5.5 ; 0 1 0 7 | 0 5 5.4 ; 0 1 0 8 | 1 6 5.3 ; 0 0 0 9 | 2 6 5.2 ; 0 0 0 10 | 3 5 5.0 ; 0 1 0 11 | 3 1 0.5 ; 0 1 0 12 | 3.0 -2.7 0.2 ; 0 1 0 13 | 3.5 -2.8 3.5 ; 0 1 1 # Top of loop 1 14 | 4.0 0.8 3.5 ; 0 1 0 15 | 4.0 1.5 1.1 ; 0 1 1 16 | 4 -0.1 0.2 ; 0 1 0 17 | 4 -2 0.2 ; 0 1 0 18 | 3.5 -3.5 5.1 ; 0 1 0 19 | 3.45 0 4.9 ; 0 1 0 # Top of loop 2 20 | 3.43 0.1 0.2 ; 0 1 0 21 | 3.5 -3 0.6 ; 0 1 0 22 | 3 -5 5.0 ; 0 1 0 23 | 4 -7 4.0 ; 0 1 0 24 | 2 -8 4.1 ; 0 0 0 25 | 1 -7.9 4.2 ; 0 0 0 26 | 0 -8 4.3 ; 0 0 0 27 | -1 -7.9 4.4 ; 0 0 0 28 | -2 -7 4.5 ; 0 0 0 29 | -3 -7.9 4.6 ; 0 0 0 30 | -4 -7 4.7 ; 0 0 0 31 | -5 -5 4.8 ; 0 1 0 32 | -5 -1 5.1 ; 0 1 0 33 | -4 0 4.5 ; 0 0 0 34 | -2 0 1.2 ; 0 0 0 35 | 4 0 1.2 ; 0 0 0 36 | 6.5 0 2.2 ; 0 0 0 37 | 5.0 0 5.2 ; 0 0 0 38 | 3.0 0 5.0 ; 0 0 0 # Top of Loop 3 39 | 2.5 -0.4 2.2 ; 0 0 0 40 | 5 -1.5 0.5 ; 0 0 0 41 | 6.5 -1.9 2.2 ; 0 0 0 42 | 3.5 0 4.5 ; 0 0 0 # Top of Loop 4 43 | 1.5 3 5.0 ; 0 0 0 44 | 0.2 4.8 3.5 ; 0 0 0 45 | 0.9 4.6 0.9 ; 0 0 0 46 | 3.3 2.0 0.5 ; 0 0 0 47 | 5 -2.5 5.4 ; 0 1 0 48 | 5 -3.5 5.3 ; 0 1 0 49 | 5 -5 5.2 ; 0 1 0 50 | 3 -7 4.7 ; 0 0 0 51 | 1 -5 4.2 ; 0 1 0 52 | 3 -3 3.7 ; 0 0 0 53 | 5 -5 3.2 ; 0 1 0 54 | 3 -7 2.7 ; 0 0 0 55 | 1 -5 2.2 ; 0 1 0 56 | 3 -3 1.7 ; 0 0 0 57 | 5 -5 1.2 ; 0 1 0 58 | 3 -7 0.7 ; 0 0 0 59 | 0 -3 0.2 ; 0 1 0 60 | 0 -2 0.2 ; 0 1 0 61 | 62 | SupportCoordinate 63 | 1 64 | 0 3.0 0 ; 0 1 6.2 65 | 66 | SupportAbscisse 67 | 61 68 | 8 69 | 25 70 | 50 71 | 60 72 | 71 73 | 82 74 | 89 75 | 103 76 | 128 77 | 139 78 | 150 79 | 163 80 | 186 # Loop 1 81 | 209 # Top of Loop 1 82 | 321 # Top of Loop 2 83 | 334 # Loop 2 84 | 392 85 | 420 86 | 425 87 | 434 88 | 444 89 | 454 90 | 464 91 | 478 92 | 488 93 | 498 94 | 510 95 | 522 96 | 534 97 | 546 98 | 558 99 | 575 100 | 595 101 | 613 102 | 625 103 | 633 # Top of Loop 3 104 | 641 # Loop 3 105 | 650 106 | 712 107 | 731 108 | 741 109 | 749 110 | 765 # Loop 4 111 | 775 # Loop 4 112 | 795 # Top of Loop 4 113 | 810 # Top of Loop 4 114 | 824 115 | 844 116 | 858 117 | 869 118 | 903 119 | 920 120 | 930 121 | 940 122 | 950 123 | 960 124 | 984 125 | 994 126 | 1005 127 | 1017 128 | 1160 #1170 129 | 130 | Box 131 | 0 -2 .2 # box coordinate 132 | 3 # box length 133 | 0 # rotation angle 134 | 135 | Tree 136 | 40 137 | 1 -1.5 0 # inside the track 138 | 2 -2 0 # inside the track 139 | -1 1.5 0 # inside the track 140 | 7 -4 0 141 | 6 0 0 142 | 5 8 0 143 | 0 5 0 144 | -5 2 0 145 | -1 -6 0 146 | -4 -4 0 147 | # those were generated with a small perl script: 148 | -3.62033995527138 -11.1114785314507 0 149 | 13.9029964349627 9.65149187575687 0 150 | 6.17812756826168 16.1461396793116 0 151 | -9.05828726674162 8.1074921020288 0 152 | -9.65397769633803 21.4203420262471 0 153 | 19.7436502041229 -12.8133539737095 0 154 | 13.5078342715755 15.6359696457117 0 155 | 4.93356845880033 15.4135018605657 0 156 | 11.4470238806508 -5.72286690999838 0 157 | 12.2514538317571 9.02148671142818 0 158 | -0.664640602892582 13.963983478364 0 159 | 18.1886411846733 11.8905977204342 0 160 | 8.83330611120551 -12.0962820021581 0 161 | -11.8635855384895 12.067966968154 0 162 | -1.70215267118739 10.5368591640589 0 163 | -0.702056634237779 -12.1065680822491 0 164 | -2.56702265186181 -10.5695213503598 0 165 | 9.00752213173868 -14.2124520920009 0 166 | 2.54341308097351 21.1880402873868 0 167 | -10.9178472749141 -12.8999052956643 0 168 | 17.495790370539 2.88025572058083 0 169 | -20.6366983450897 13.7725400098549 0 170 | 2.47873164219668 -12.7618395912889 0 171 | -6.36520630805519 18.5435038401076 0 172 | 13.2660788808759 -10.1727556251597 0 173 | 8.65746947328433 -10.3697048116768 0 174 | -8.72148787584757 -12.4433590904693 0 175 | -8.96907330103783 -7.4251822129953 0 176 | 13.4007674080207 -9.77626079296423 0 177 | -10.4671651105466 3.40865499019243 0 178 | 179 | StartSegment 180 | -10 181 | 182 | BrakeSegment 183 | -54 184 | 185 | TiltFactor 186 | 4 187 | 188 | -------------------------------------------------------------------------------- /demo/INSTALL: -------------------------------------------------------------------------------- 1 | HOW TO COMPILE UNDER LINUX ? 2 | ============================ 3 | Check the Makefile and if necessary modify it according to your system 4 | configuration. 5 | 6 | Then make it by typing make. 7 | 8 | To execute the animation, make sure that the current directory is the one 9 | containing the executable file and type ./roller 10 | 11 | It should be easy to compile under other unix systems. The provided 12 | Makefile.irix has been used to build RollerCoaster2000 on an Onyx machine. 13 | 14 | HOW TO COMPILE UNDER WINDOWS ? 15 | ============================== 16 | The provided Makefile.win32 can be used with the lcc-win32 free compiler. This 17 | compiler is downloadable from http://www.cs.virginia.edu/~lcc-win32 18 | 19 | You can download GLUT for win32 from http://www.xmission.com/~nate/glut.html 20 | However you can't use the glut32.lib file that come with GLUT dll and header, 21 | because it wasn't produced with lcc-win32. 22 | 23 | Although lcc-win32 has its own glut32.lib, you have to modify it before you can 24 | compile. To do so open the file glut32.exp that lies in lcc's buildlib 25 | directory with a text editor. Add the following lines at the beginning of this 26 | file, after the line containing GLUT32.DLL: 27 | 28 | ____glutGetFCB@4 29 | ____glutSetFCB@8 30 | ___glutCreateMenuWithExit@8 31 | ___glutCreateWindowWithExit@8 32 | ___glutInitWithExit@12 33 | 34 | After that, open a shell (msdos prompt), make sure that lcc's bin directory is 35 | in your PATH environment variable, go in lcc's buildlib directory and type: 36 | buildlib glut32.exp 37 | This commands generates a file called glut32.lib. Move this file in lcc's 38 | library directory. 39 | 40 | Now you are ready to compile by typing make. You can type make -f Makefile.win32 41 | or you can rename Makefile.win32 to Makefile and just call make. 42 | 43 | Alternatively, the provided Makefile.vc can be used to compile with Visual 44 | Studio. 45 | -------------------------------------------------------------------------------- /demo/Midnight_madness.trk: -------------------------------------------------------------------------------- 1 | # Midnight madness, made by Kevin Ellis 2 | 3 | track 4 | 34 5 | 2 8 .29 ; 0 1 0 6 | 2 4 .3 ; 0 1 0 7 | 2 -3 5 ; 0 0 .1 8 | 2 -8 .6 ; 0 1 0 9 | 2 -10 4 ; 0 0 0 10 | 0 -12 4.9 ; 0 0 0 11 | -2 -10 3.6 ; 0 1 -1 12 | -2 -6 .3 ; 0 1 .5 13 | -1.9 -4 2.5 ; 0 0 1 14 | -1.8 -5.5 4 ; -1 5 0 15 | -1.6 -7 2.5 ; 0 0 1 16 | -1.6 -5 .3 ; 0 0 0 17 | -1.6 -2 .3 ; 0 0 0 18 | -3.6 0 .5 ; 0 0 0 19 | -6 -2 .7 ; 0 0 0 20 | -3.6 -4 .9 ; 0 0 0 21 | -1.6 -2 1.1 ; 0 1 0 22 | -1 3 3 ; 0 0 0 23 | -5 7 .4 ; 0 0 0 24 | -2 11 2.5 ; 0 0 0 25 | 4 9 1.5 ; 0 .5 1 26 | 4 6 .3 ; 0 1 0 27 | 4 0 1.4 ; .5 1 0 28 | -4 -6.7 2.5 ; 1 0 0 29 | -7 -8 1 ; 0 1 1 30 | 2 -11.1 2 ; 1 0 0 31 | 6 -9 .2 ; 0 1 0 32 | 6 -5 2.5 ; 0 1 0 33 | 6 -1 .2 ; 0 1 0 34 | 6 3 2.5 ; 0 1 0 35 | 6 7 .2 ; 0 1 0 36 | 6 9.5 .2 ; 0 1 0 37 | 4 11.5 .2 ; 1 0 0 38 | 2 9.5 .2 ; 0 1 0 39 | 40 | 41 | supportcoordinate 42 | 1 43 | 2 -19.5 0, 0 -1 7 44 | 45 | Box 46 | 47 | 2 6 .3 48 | 4 49 | 1 50 | 51 | Tree 52 | 20 53 | 2.5 6 0 54 | -8 0 0 55 | -4 1 0 56 | -4 -2 0 57 | -8 5 0 58 | -6 6 0 59 | -1 -10 0 60 | 0 -8 0 61 | -0.5 3 0 62 | 3 -8 0 63 | 5 -2 0 64 | 2.5 7 0 65 | 2.5 8 0 66 | 2.5 9 0 67 | 1 9 0 68 | 1 8 0 69 | 1 7 0 70 | 1 6 0 71 | 1 5 0 72 | 2.5 5 0 73 | 74 | TiltFactor 75 | 10 76 | 77 | SupportAbscisse 78 | 52 79 | 30 80 | 40 81 | 60 82 | 80 83 | 100 84 | 120 85 | 140 86 | 160 87 | 180 88 | 210 89 | 220 90 | 240 91 | 260 92 | 300 93 | 360 94 | 380 95 | 400 96 | 420 97 | 440 98 | 460 99 | 480 100 | 500 101 | 520 102 | 540 103 | 560 104 | 580 105 | 600 106 | 620 107 | 640 108 | 660 109 | 680 110 | 700 111 | 720 112 | 740 113 | 760 114 | 780 115 | 800 116 | 820 117 | 840 118 | 860 119 | 880 120 | 900 121 | 920 122 | 940 123 | 960 124 | 980 125 | 1000 126 | 1020 127 | 1040 128 | 1060 129 | 1080 130 | 1100 131 | 132 | BrakeSegment 133 | -25 134 | -------------------------------------------------------------------------------- /demo/QuadraPhase.trk: -------------------------------------------------------------------------------- 1 | # QUADRAPHASE - A RollerCoaster2000 Track by Ken Ives 2 | 3 | Track 4 | 97 5 | 6 | 0.1 0 2.22 ; 0 0 0 7 | 1.3 3.0 6.0 ; 0 0 0 # Top of Lifthill 8 | 4.0 -0.5 1.0 ; 0 1 0 9 | 10 | 4.25 -2.4 2.0 ; 0 0 0 11 | 4.23 -3.5 3.7 ; 0 0 0 12 | 4 -2 5.7 ; 0 0 0 # Top of Octopussy Loop 1 13 | 3.95 -0.5 4.0 ; 0 0 0 14 | 3.65 -2.0 2.1 ; 0 0 0 15 | 16 | 4.7 -5.7 0.8 ; 0 0 0 17 | 5.7 -7.0 2.2 ; 0 0 0 18 | 5.2 -6.3 4.0 ; 0 0 0 # Top of Quadraloop 1 19 | 4.2 -5.3 3.0 ; 0 0 0 20 | 21 | 5.2 -6.0 1.5 ; 0 0 0 22 | 6.2 -6.3 3.0 ; 0 0 0 23 | 5.0 -6.1 4.5 ; 0 0 0 # Top of Quadraloop 2 24 | 3.9 -6.1 3.5 ; 0 0 0 25 | 26 | 5.0 -6.0 2.0 ; 0 0 0 27 | 6.0 -5.4 3.5 ; 0 0 0 28 | 5.0 -6.0 5.0 ; 0 0 0 # Top of Quadraloop 3 29 | 3.8 -7.0 4.1 ; 0 0 0 30 | 31 | 4.8 -6.2 2.5 ; 0 0 0 32 | 5.3 -4.8 4.0 ; 0 0 0 33 | 5.0 -6.0 5.6 ; 0 0 0 # Top of Quadraloop 4 34 | 4.6 -7.2 3.8 ; 0 0 0 35 | 4.80 -5 2.7 ; 0 0 0 36 | 37 | 4.90 -3.5 2.4 ; 0 0 0 38 | 39 | 4.15 -1.85 2.5 ; 0 0 0 40 | 3.0 -1.0 4.2 ; 0 0 0 41 | 4 -2 5.7 ; 0 0 0 # Top of Octopussy Loop 2 42 | 4.9 -2.9 4.1 ; 0 0 0 43 | 3.90 -2.40 2.6 ; 0 0 0 44 | 45 | 2.7 -1.2 2.1 ; 0 0 0 46 | 47 | 1.5 -0.3 2.0 ; 0 0 0 # Bottom of Spring Spiral 48 | 0.5 1.5 2.0 ; 0 1 0.101 49 | 1.5 2.5 2.2 ; 0 0 0.0 50 | 2.5 1.5 2.4 ; 0 1 -0.101 51 | 1.5 0.5 2.6 ; 0 0 0.0 52 | 53 | 0.5 1.5 2.8 ; 0 1 0.101 54 | 1.5 2.5 3.0 ; 0 0 0.0 55 | 2.5 1.5 3.2 ; 0 1 -0.101 56 | 1.5 0.5 3.4 ; 0 0 0.0 57 | 0.5 1.5 3.6 ; 0 1 0.101 58 | 59 | 1.5 2.5 3.8 ; 0 0 0.0 60 | 2.5 1.5 4.0 ; 0 1 -0.101 61 | 1.5 0.5 4.2 ; 0 0 0.0 62 | 0.5 1.5 4.4 ; 0 1 0.101 63 | 1.5 2.5 4.6 ; 0 0 0.0 64 | 65 | 2.5 1.5 4.8 ; 0 1 -0.101 66 | 1.5 0.5 5.0 ; 0 0 0.0 67 | 0.5 1.5 5.2 ; 0 1 0.101 68 | 1.5 2.5 5.4 ; 0 0 0.0 69 | 2.5 1.5 5.5 ; 0 1 -0.101 70 | 71 | 1.5 0.5 5.7 ; 0 0 0 # Top of Spring Spiral 72 | 0.8 1.2 5.6 ; 0 0 0 73 | 1.5 1.5 4.5 ; 0 0 0 74 | 2.3 1.2 0.8 ; 0 0 0 75 | 3.5 -1.5 0.2 ; 0 0 0 # Exit Spring Spiral 76 | 77 | 2.0 -4.5 1.3 ; 0 0 0 78 | 0.4 -5.0 5.0 ; 0 0 0 79 | 0.0 -3.5 5.9 ; 0 0 0 80 | 0.4 -2.0 5.0 ; 0 0 0 81 | 2.8 -1.8 2.0 ; 0 0 0 82 | 83 | 4.3 -1.6 2.0 ; 0 0 0 84 | 5.5 -1.8 4.0 ; 0 0 0 85 | 4 -2 5.7 ; 0 0 0 # Top of Octopussy Loop 3 86 | 2.5 -2.15 4.0 ; 0 0 0 87 | 4.2 -2.25 1.0 ; 1 0 0 88 | 89 | 5.8 -2.25 1.0 ; 1 0 0 90 | 7.85 -1.95 3.0 ; 0 0 1 # Enter Spiral Loop 91 | 7 -1 4.4 ; 0 0 0 92 | 5.9 0.1 3.0 ; 0 0 0 93 | 7 -1 1.3 ; 0 0 0 94 | 95 | 8.2 -2.2 3.1 ; 0 0 0 96 | 7 -1 4.7 ; 0 0 0 97 | 5.7 0.3 3.0 ; 0 0 0 98 | 7 -1 1.0 ; 0 0 0 99 | 8.4 -2.4 3.1 ; 0 0 0 100 | 101 | 7 -1 5.0 ; 0 0 0 102 | 5.5 0.5 3.0 ; 0 0 0 103 | 7 -1 0.7 ; 0 0 0 104 | 8.66 -2.66 3.0 ; 0 0 0 105 | 7.57 -0.13 5.2 ; 0 0 -0.2 # Top of Spiral Loop 106 | 107 | 7.4 -0.7 3.2 ; 0 0 0 108 | 5.0 -1.1 2.6 ; 0 0 0 109 | 110 | 4.2 -1.7 2.85 ; 0 0 0 111 | 3.2 -2.9 4.2 ; 0 0 0 112 | 4 -2 5.7 ; 0 0 0 # Top of Octopussy Loop 4 113 | 5 -1 4.0 ; 0 0 0 114 | 3.6 -1.25 1.8 ; 0 0 0 115 | 116 | 1.0 -3.0 1.0 ; 0 0 0 117 | 3.0 -6 0.5 ; 0 0 0 118 | 2.8 -9 1.0 ; 0 0 0 119 | 120 | 3.0 -12 0.5 ; 0 0 0 121 | 1.5 -13.5 0.3 ; 0 0 0 122 | 0 -12 0.2 ; 0 0 0 123 | 0.0 -5 1.5 ; 0 0 0 124 | 0 -3 1.5 ; 0 1 0 125 | 126 | SupportCoordinate 127 | 1 128 | 0 -3.5 0 ; 0 1 6.85 129 | 130 | SupportAbscisse 131 | 69 132 | 133 | 0 134 | 17 135 | 34 136 | 55 137 | 68 138 | 85 139 | 102 140 | 122 141 | 134 142 | 142 143 | 172 144 | 266 145 | 301 146 | 337 147 | 400 148 | 440 149 | 482 150 | 532 151 | 571 152 | 625 153 | 670 # Quadraloop Exit 154 | 686 155 | 712 156 | 805 157 | 825 158 | 842 # Spring Spiral Start 159 | 855 160 | 868 161 | 885 162 | 1159 163 | 1175 164 | 1195 # Spring Spiral Exit 165 | 1215 166 | 1235 167 | 1257 168 | 1275 169 | 1295 170 | 1310 171 | 1325 172 | 1361 173 | 1377 174 | 1393 175 | 1407 176 | 1420 177 | 1490 178 | 1545 179 | 1570 # Spiral Loop Entry 180 | 1599 181 | 1612 182 | 1630 183 | 1685 184 | 1950 185 | 1960 186 | 1978 187 | 2017 188 | 2031 189 | 2128 190 | 2178 191 | 2200 192 | 2220 193 | 2240 194 | 2260 195 | 2280 196 | 2300 197 | 2320 198 | 2340 199 | 2360 200 | 2380 201 | 2395 202 | 203 | Box 204 | 0 -2.5 1.5 # box coordinate 205 | 3 # box length 206 | 0 # rotation angle 207 | 208 | 209 | StartSegment 210 | -20 211 | 212 | BrakeSegment 213 | -105 214 | 215 | TiltFactor 216 | 7 217 | 218 | AverageSegmentLength 219 | 0.1 220 | 221 | Tree 222 | 81 223 | 224 | # End Segment Trees 225 | -0.7 -14 0 226 | -0.7 -13 0 227 | -0.7 -12 0 228 | -0.7 -11 0 229 | -0.7 -10 0 230 | -0.7 -9 0 231 | -0.7 -8 0 232 | -0.7 -7 0 233 | -0.7 -6 0 234 | -0.7 -5 0 235 | 0.5 -14 0 236 | 0.5 -11.5 0 237 | 0.5 -10.5 0 238 | 0.5 -9.5 0 239 | 0.5 -8.5 0 240 | 0.5 -7.5 0 241 | 0.5 -6.5 0 242 | 0.5 -5.5 0 243 | 0.5 -4.5 0 244 | 1.2 -14 0 245 | 1.2 -12 0 246 | 1.2 -11 0 247 | 1.2 -10 0 248 | 1.2 -9 0 249 | 1.2 -8 0 250 | 1.2 -7 0 251 | 1.2 -6 0 252 | 1.2 -5 0 253 | 1.7 -12.5 0 254 | 1.7 -11.5 0 255 | 1.7 -10.5 0 256 | 1.7 -9.5 0 257 | 1.7 -8.5 0 258 | 1.7 -7.5 0 259 | 1.7 -6.5 0 260 | 1.7 -5.5 0 261 | 2.3 -14 0 262 | 2.3 -12 0 263 | 2.3 -11 0 264 | 2.3 -10 0 265 | 2.3 -9 0 266 | 2.3 -8 0 267 | 2.3 -7 0 268 | 2.3 -6 0 269 | 3.5 -13.5 0 270 | 3.5 -12.5 0 271 | 3.5 -11.5 0 272 | 3.5 -10.5 0 273 | 3.5 -9.5 0 274 | 3.5 -8.5 0 275 | 3.5 -7.5 0 276 | # Landscape trees borrowed from Freestyle track 277 | # those were generated with a small perl script: 278 | -3.62033995527138 -11.1114785314507 0 279 | 13.9029964349627 9.65149187575687 0 280 | 6.17812756826168 16.1461396793116 0 281 | -9.05828726674162 8.1074921020288 0 282 | -9.65397769633803 21.4203420262471 0 283 | 19.7436502041229 -12.8133539737095 0 284 | 13.5078342715755 15.6359696457117 0 285 | 4.93356845880033 15.4135018605657 0 286 | 11.4470238806508 -5.72286690999838 0 287 | 12.2514538317571 9.02148671142818 0 288 | -0.664640602892582 13.963983478364 0 289 | 18.1886411846733 11.8905977204342 0 290 | 8.83330611120551 -12.0962820021581 0 291 | -11.8635855384895 12.067966968154 0 292 | -1.70215267118739 10.5368591640589 0 293 | -3.702056634237779 -12.1065680822491 0 294 | -2.56702265186181 -10.5695213503598 0 295 | 9.00752213173868 -14.2124520920009 0 296 | 2.54341308097351 21.1880402873868 0 297 | -10.9178472749141 -12.8999052956643 0 298 | 17.495790370539 2.88025572058083 0 299 | -20.6366983450897 13.7725400098549 0 300 | -2.47873164219668 -12.7618395912889 0 301 | -6.36520630805519 18.5435038401076 0 302 | 13.2660788808759 -10.1727556251597 0 303 | 8.65746947328433 -10.3697048116768 0 304 | -8.72148787584757 -12.4433590904693 0 305 | -8.96907330103783 -7.4251822129953 0 306 | 13.4007674080207 -9.77626079296423 0 307 | -10.4671651105466 3.40865499019243 0 308 | -------------------------------------------------------------------------------- /demo/README: -------------------------------------------------------------------------------- 1 | RollerCoaster2000 by Plusplus 2 | 3 | plusplus@free.fr 4 | 5 | http://plusplus.free.fr/rollercoaster 6 | 7 | 8 | Introduction 9 | ------------ 10 | RollerCoaster2000 is a rollercoaster simulator which generates the track from a 11 | description of it stored in a text file. So it should be easy to create new 12 | tracks (as long as you keep a pencil and a paper near your computer to draw 13 | control points and tangents :-). For the track file format see track_format.txt 14 | 15 | Requirements 16 | ------------ 17 | * GLUT 3.7 (for information see: 18 | http://www.opengl.org/developers/documentation/glut.html) 19 | * It's also surely better with a 3D hardware accelerator with proper OpenGL 20 | driver. 21 | 22 | Installation 23 | ------------ 24 | For information about compiling RollerCoaster2000, see the file INSTALL. 25 | 26 | Use 27 | --- 28 | You can run RollerCoaster2000 by changing to its directory, and typing ./roller 29 | on your console. 30 | 31 | You can also specify some options: 32 | -h print this help 33 | -f select fullscreen mode 34 | -s select stereoscopic mode (for use with a stereo display device) 35 | -c {1|5|6} select C.A.V.E. mode(5 or 6 screens, or 1 for normal mode) 36 | -t select a file containing a track description (default rc2k.trk) 37 | -x select window width (default 800) 38 | -y select window height (default 600) 39 | -i disables intro(skip straight to ride) 40 | 41 | When running fullscreen, both under Linux and Windows, GLUT keeps the same 42 | screen resolution as the desktop resolution. So specifying width and height has 43 | no effect. 44 | 45 | When the animation plays: 46 | left/right arrow keys modify field of view angle 47 | up/down arrow keys modify the focal length (useful only with stereo mode) 48 | +/- keys modify distance between eyes (useful only with stereo mode) 49 | 50 | Stereoscopic and CAVE mode are mutually exclusive. When using CAVE display mode 51 | the given width and height are for a single viewport. Since CAVE mode can 52 | display up to 6 viewports, the size of the complete window will be 3*width by 53 | 2*height. You should use a square resolution so that the border of adjacent 54 | viewports match. The CAVE display mode has been tested by Rodrigo Damazio on an 55 | Onyx machine with the program ircombine. The caveroller shell script should 56 | help launching RollerCoaster2000 with CAVE display mode. 57 | 58 | License 59 | ------- 60 | RollerCoaster2000 is distributed under the General Public License (see the 61 | COPYING file). 62 | 63 | Disclaimer 64 | ---------- 65 | Use only at your own risk! Although this is highly unlikely to happen, I can't 66 | be responsible for any damage caused by this software. 67 | 68 | Thanks 69 | ------ 70 | Rodrigo Damazio : Implementation and test of the C.A.V.E. 71 | display mode. 72 | 73 | Jeff Molofee: Great OpenGL tutorials at http://nehe.gamedev.net 74 | 75 | Jason Allen: The glBMP library included in this project is derived from the C++ 76 | version that you can find at Jason's site http://delphigl.cfxweb.net 77 | 78 | Paul Bourke: Explanation of how to create stereo images can be found on his 79 | site at http://astronomy.swin.edu.au/pbourke/stereographics/ 80 | 81 | Armin Hopp: His company http://www.digital-image.de provides with virtual 82 | reality systems. Helped by testing stereoscopic version. 83 | -------------------------------------------------------------------------------- /demo/cave.h: -------------------------------------------------------------------------------- 1 | /* CAVE port addition 2 | * by Rodrigo Damazio 3 | */ 4 | 5 | #ifndef ROLLER_CAVE_H 6 | #define ROLLER_CAVE_H 7 | 8 | /* Viewport definitions 9 | * The cave works by splitting the window in 6 pieces, one for each sceen. 10 | * Here we define macros to address all of them. 11 | * Further changes would be required for a multi-pipe or cluster system. 12 | */ 13 | 14 | #define bottom_left \ 15 | glViewport(0, 0, wndWidth, wndHeight); 16 | 17 | #define bottom_center \ 18 | glViewport(wndWidth, 0, wndWidth, wndHeight); 19 | 20 | #define bottom_right \ 21 | glViewport(wndWidth*2, 0, wndWidth, wndHeight); 22 | 23 | #define top_left \ 24 | glViewport(0, wndHeight, wndWidth, wndHeight); 25 | 26 | #define top_center \ 27 | glViewport(wndWidth, wndHeight, wndWidth, wndHeight); 28 | 29 | #define top_right \ 30 | glViewport(wndWidth*2, wndHeight, wndWidth, wndHeight); 31 | 32 | /* Projection definitions 33 | * Here we define the rotation necessary for each projection. 34 | */ 35 | #define draw_front DrawGLScene(0,0) 36 | #define draw_left DrawGLScene(M_PI/2,0) 37 | #define draw_right DrawGLScene(-M_PI/2,0) 38 | #define draw_back DrawGLScene(M_PI,0) 39 | #define draw_bottom DrawGLScene(0,-M_PI/2) 40 | #define draw_top DrawGLScene(0,M_PI/2) 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /demo/caveroller: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | setmon -n main 4 | 5 | ./roller -x 640 -y 640 -f -i -s -c 5 $* 6 | 7 | setmon -n padrao 8 | -------------------------------------------------------------------------------- /demo/demo.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 18 | 19 | 20 | 21 | 22 | 29 | 32 | 35 | 38 | 41 | 44 | 56 | 59 | 62 | 65 | 74 | 77 | 80 | 83 | 86 | 89 | 92 | 95 | 96 | 103 | 106 | 109 | 112 | 115 | 119 | 131 | 134 | 137 | 140 | 148 | 151 | 154 | 157 | 160 | 163 | 166 | 172 | 174 | 175 | 183 | 186 | 189 | 192 | 195 | 198 | 210 | 213 | 216 | 219 | 230 | 233 | 236 | 239 | 242 | 245 | 248 | 251 | 252 | 260 | 263 | 266 | 269 | 272 | 276 | 289 | 292 | 295 | 298 | 309 | 312 | 315 | 318 | 321 | 324 | 327 | 333 | 335 | 336 | 337 | 338 | 339 | 340 | 345 | 348 | 349 | 352 | 353 | 356 | 357 | 360 | 361 | 364 | 365 | 368 | 369 | 370 | 375 | 378 | 379 | 382 | 383 | 386 | 387 | 390 | 391 | 394 | 395 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | -------------------------------------------------------------------------------- /demo/freestyle.trk: -------------------------------------------------------------------------------- 1 | Track 2 | 33 # number of control points 3 | 4 -2 .2 ; 0 0 0 4 | 3 0 .21 ; -.5 1 0 5 | 2 2 3.5 ; 0 0 0 6 | 0 3 3.4 ; 0 0 0 7 | -3 0 .2 ; 0 0 0 8 | -3 -2 2.5 ; 0 0 0 9 | 0 -3 .2 ; 1 0 0 10 | 1 -3.1 1.2 ; 0 0 0 11 | 0 -3.2 2.2 ; 0 0 0 # top of the first double loop's loop 12 | -1 -3.3 1.2 ; 0 0 0 13 | 0 -3.4 .2 ; 1 0 0 14 | .5 -3.4 .2 ; 1 0 0 15 | 1.5 -3.5 1.2 ; 0 0 0 16 | .5 -3.6 2.2 ; 0 0 0 # top of the second double loop's loop 17 | -.5 -3.7 1.2 ; 0 0 0 18 | .5 -3.8 .2 ; 1 0 0 19 | 4 -4 2.5 ; 0 0 0 20 | 4 -1 3 ; 0 0 0 21 | 2 2 1 ; 0 0 0 22 | -3 -2 1 ; 0 0 0 23 | -3 3 3.3 ; 0 0 0 24 | 0 3.3 .7 ; 0 0 0 25 | 2 3.5 .2 ; 0 0 0 26 | 3.5 3.4 1.7 ; 0 0 0 27 | 2 3.3 3.2 ; 0 0 0 # top of the third loop 28 | 0.5 3.2 1.7 ; 0 0 0 29 | 2 3.1 .3 ; 1 0 0 30 | 4 2 .3 ; 0 0 0 31 | 3 0 2 ; 0 0 0 32 | 0 -1 3 ; 0 0 0 33 | -3 -3 1 ; 0 0 0 34 | 0 -5 .2 ; 4 -.5 0 35 | 5 -4 .2 ; -.5 1 0 36 | 37 | SupportCoordinate 38 | 13 # number of supports 39 | .98 -3.05 1 ; 1 0 0 # first loop of the double loop 40 | -.98 -3.35 1 ; 1 0 0 # first loop of the double loop 41 | 0 -3 1 ; 1 0 0 # first loop of the double loop 42 | .25 -3.4 1 ; 1 0 0 # between the loops of the double loop 43 | 1.48 -3.45 1 ; 1 0 0 # second loop of the double loop 44 | .5 -3.8 1 ; 1 0 0 # second loop of the double loop 45 | -.48 -3.75 1 ; 1 0 0 # second loop of the double loop 46 | 4.44 -2.88 0 ; -.5 1 -.18 # support which lies upon the box 47 | 2 3.5 1 ; 1 0 0 # third loop 48 | 3.4 3.4 0 ; 1 0 0 # third loop 49 | 1 3.05 2 ; 1 0 0 # third loop 50 | 2.5 3.05 1 ; 1 0 0 # after the third loop 51 | 0 -1 0 ; -2 -1 4.5 52 | 53 | SupportAbscisse 54 | 31 # number of supports 55 | 50 56 | 75 57 | 95 58 | 115 59 | 135 60 | 155 61 | # triple crossing 62 | 200 63 | # the double loop 64 | 375 65 | 400 66 | 450 67 | 470 68 | 490 69 | 510 70 | 530 71 | 550 # triple crossing 72 | 555 # triple crossing 73 | 575 74 | 595 75 | 615 76 | 635 77 | 655 78 | # the third loop 79 | 800 80 | 823 81 | 840 82 | 855 83 | # support defined with coordinate with the logo 84 | 887 85 | 920 86 | 940 87 | 960 88 | 980 89 | 1000 90 | 91 | BrakeSegment 92 | -40 93 | 94 | StartSegment 95 | 10 96 | 97 | Box 98 | 4 -2 .2 # box coordinate 99 | 4 # box length 100 | 206.565 # rotation angle 101 | 102 | Tree 103 | 40 104 | 1 -1.5 0 # inside the track 105 | 2 -2 0 # inside the track 106 | -1 1.5 0 # inside the track 107 | 7 -4 0 108 | 6 0 0 109 | 5 3 0 110 | 0 5 0 111 | -5 2 0 112 | -1 -6 0 113 | -4 -4 0 114 | # those were generated with a small perl script: 115 | -3.62033995527138 -11.1114785314507 0 116 | 13.9029964349627 9.65149187575687 0 117 | 6.17812756826168 16.1461396793116 0 118 | -9.05828726674162 8.1074921020288 0 119 | -9.65397769633803 21.4203420262471 0 120 | 19.7436502041229 -12.8133539737095 0 121 | 13.5078342715755 15.6359696457117 0 122 | 4.93356845880033 15.4135018605657 0 123 | 11.4470238806508 -5.72286690999838 0 124 | 12.2514538317571 9.02148671142818 0 125 | -0.664640602892582 13.963983478364 0 126 | 18.1886411846733 11.8905977204342 0 127 | 8.83330611120551 -12.0962820021581 0 128 | -11.8635855384895 12.067966968154 0 129 | -1.70215267118739 10.5368591640589 0 130 | -0.702056634237779 -12.1065680822491 0 131 | -2.56702265186181 -10.5695213503598 0 132 | 9.00752213173868 -14.2124520920009 0 133 | 2.54341308097351 21.1880402873868 0 134 | -10.9178472749141 -12.8999052956643 0 135 | 17.495790370539 2.88025572058083 0 136 | -20.6366983450897 13.7725400098549 0 137 | 2.47873164219668 -12.7618395912889 0 138 | -6.36520630805519 18.5435038401076 0 139 | 13.2660788808759 -10.1727556251597 0 140 | 8.65746947328433 -10.3697048116768 0 141 | -8.72148787584757 -12.4433590904693 0 142 | -8.96907330103783 -7.4251822129953 0 143 | 13.4007674080207 -9.77626079296423 0 144 | -10.4671651105466 3.40865499019243 0 145 | 146 | TiltFactor 147 | 5 148 | 149 | AverageSegmentLength 150 | .1 # default is 0.15 151 | # if you modify this, the supports won't match any more 152 | -------------------------------------------------------------------------------- /demo/glbmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RollerCoaster2000 3 | * Copyright (C) 2003 Plusplus (plusplus@free.fr) 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef __CGLBMP__ 21 | #define __CGLBMP__ 22 | 23 | #ifdef _WIN32 24 | #include 25 | #endif 26 | 27 | #include 28 | 29 | #ifndef _WIN32 30 | /* 31 | * the following definitions replaces windows headers definition 32 | * for BMP manipulation 33 | */ 34 | #define BI_RGB 0 35 | #define BI_BITFIELDS 3 36 | 37 | typedef unsigned char BYTE; 38 | typedef unsigned short WORD; 39 | typedef unsigned long DWORD; 40 | typedef long LONG; 41 | 42 | typedef struct 43 | { 44 | BYTE rgbBlue; 45 | BYTE rgbGreen; 46 | BYTE rgbRed; 47 | BYTE rgbReserved; 48 | } RGBQUAD; 49 | 50 | typedef struct 51 | { 52 | BYTE rgbtBlue; 53 | BYTE rgbtGreen; 54 | BYTE rgbtRed; 55 | } RGBTRIPLE; 56 | 57 | typedef struct 58 | { 59 | WORD bfType __attribute__((packed)); 60 | DWORD bfSize __attribute__((packed)); 61 | WORD bfReserved1 __attribute__((packed)); 62 | WORD bfReserved2 __attribute__((packed)); 63 | DWORD bfOffBits __attribute__((packed)); 64 | } BITMAPFILEHEADER; 65 | 66 | typedef struct 67 | { 68 | DWORD biSize __attribute__((packed)); 69 | LONG biWidth __attribute__((packed)); 70 | LONG biHeight __attribute__((packed)); 71 | WORD biPlanes __attribute__((packed)); 72 | WORD biBitCount __attribute__((packed)); 73 | DWORD biCompression __attribute__((packed)); 74 | DWORD biSizeImage __attribute__((packed)); 75 | LONG biXPelsPerMeter __attribute__((packed)); 76 | LONG biYPelsPerMeter __attribute__((packed)); 77 | DWORD biClrUsed __attribute__((packed)); 78 | DWORD biClrImportant __attribute__((packed)); 79 | } BITMAPINFOHEADER; 80 | 81 | typedef struct 82 | { 83 | DWORD bcSize; 84 | WORD bcWidth; 85 | WORD bcHeight; 86 | WORD bcPlanes; 87 | WORD bcBitCount; 88 | } BITMAPCOREHEADER; 89 | 90 | #endif /* #ifndef _WIN32 */ 91 | 92 | typedef struct 93 | { 94 | BYTE red; 95 | BYTE green; 96 | BYTE blue; 97 | } GLRGBTRIPLE; 98 | 99 | typedef struct 100 | { 101 | BYTE red; 102 | BYTE green; 103 | BYTE blue; 104 | BYTE alpha; 105 | } GLRGBQUAD; 106 | 107 | typedef struct 108 | { 109 | BYTE tfType; 110 | BYTE tfColorMapType; 111 | BYTE tfImageType; 112 | BYTE tfColorMapSpec[5]; 113 | BYTE tfOrigX[2]; 114 | BYTE tfOrigY[2]; 115 | BYTE tfWidth[2]; 116 | BYTE tfHeight[2]; 117 | BYTE tfBpp; 118 | BYTE tfImageDes; 119 | } TGAHEADER; 120 | 121 | 122 | typedef struct 123 | { 124 | GLuint texID; 125 | int width; 126 | int height; 127 | int colorDepth; 128 | 129 | GLRGBQUAD *pData; 130 | RGBQUAD colors[256]; 131 | 132 | DWORD redMask; 133 | DWORD greenMask; 134 | DWORD blueMask; 135 | 136 | GLint texWrapS; 137 | GLint texWrapT; 138 | GLint minFilter; 139 | GLint magFilter; 140 | 141 | int imageSize; 142 | } glBmpImage; 143 | 144 | 145 | void glBmpInit(glBmpImage* img); 146 | 147 | int glBmpLoadImage(glBmpImage* img, char szFileName[]); 148 | // bool SaveImage(char szFileName[]); 149 | 150 | int glBmpSaveScreen(glBmpImage* img); 151 | 152 | int glBmpInvert(glBmpImage* img); 153 | int glBmpFlipVert(glBmpImage* img); 154 | int glBmpFlipHorz(glBmpImage* img); 155 | int glBmpRotate180(glBmpImage* img); 156 | 157 | void glBmpGenTexture(glBmpImage* img); 158 | void glBmpGenTextureMipMap(glBmpImage* img); 159 | void glBmpSetTextureWrap(glBmpImage* img, GLint s, GLint y); 160 | void glBmpSetFilter(glBmpImage* img, GLint min, GLint mag); 161 | void glBmpBind(glBmpImage* img); 162 | 163 | int glBmpGetWidth(glBmpImage* img); 164 | int glBmpGetHeight(glBmpImage* img); 165 | int glBmpGetColorDepth(glBmpImage* img); 166 | 167 | int glBmpLoadBMP(glBmpImage* img, char *filename); 168 | int glBmpLoadTGA(glBmpImage* img, char *filename); 169 | 170 | int glBmpMemLoadBMP(glBmpImage* img, char *filePtr); 171 | int glBmpMemLoadTGA(glBmpImage* img, char *filePtr); 172 | 173 | int glBmpSaveBMP(glBmpImage* img, char *filename); 174 | int glBmpSaveTGA(glBmpImage* img, char *filename); 175 | 176 | int glBmpSaveGLBuffer(glBmpImage* img, char szFileName[]); 177 | 178 | #endif /* #ifndef __CGLBMP__ */ 179 | -------------------------------------------------------------------------------- /demo/grass.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hmwill/SC/cc86685ba50beded5bc88e462c4e8c1d28770b57/demo/grass.tga -------------------------------------------------------------------------------- /demo/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * RollerCoaster2000 3 | * Copyright (C) 2003 Plusplus (plusplus@free.fr) 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | //#include "ug.h" 21 | #include 22 | #include "gl.h" 23 | #include "vgl.h" 24 | //#include "ug.h" 25 | 26 | //#include 27 | #include 28 | #include 29 | 30 | #include "roller.h" 31 | 32 | #define WINDOW_WIDTH 400 33 | #define WINDOW_HEIGHT 300 34 | 35 | /* Re-introduce 32-bit word encoding of 32-bit RGBA values */ 36 | #define GL_UNSIGNED_INT_8_8_8_8 0x8035 37 | #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 38 | 39 | /* The number of our GLUT window */ 40 | int window; 41 | SDL_Surface *sdlSurface; 42 | VGL_Surface glSurface; 43 | 44 | int width = WINDOW_WIDTH; 45 | int height = WINDOW_HEIGHT; 46 | int fullscreen = 0; 47 | int caveMode = 1; 48 | static int stereoFlag = 0; 49 | float viewAngle = 60.0f; 50 | static float eyeDist = 0.005f; 51 | static float focalLength = 0.05f; 52 | char *trackName = "freestyle.trk"; /* name of the file containing track description */ 53 | int intro = 0; 54 | 55 | 56 | void display(void) 57 | { 58 | DrawRoller(); 59 | vglSwapBuffers(sdlSurface, glSurface); 60 | } 61 | 62 | 63 | void resize(int x, int y) 64 | { 65 | if(caveMode==5 || caveMode==6) 66 | { 67 | x /= 3; 68 | y /= 2; 69 | } 70 | ReSizeGLScene(x,y); 71 | glScissor(WINDOW_WIDTH/10, WINDOW_HEIGHT/10, WINDOW_WIDTH*7/10, WINDOW_HEIGHT*7/10); 72 | glEnable(GL_SCISSOR_TEST); 73 | display(); 74 | } 75 | 76 | #define ESCAPE 27 77 | 78 | #if 0 79 | void keyboard(unsigned char key, int x, int y) 80 | { 81 | switch(key) 82 | { 83 | case '+': 84 | eyeDist += 0.0001f; 85 | ChangeRollerParameters(viewAngle,eyeDist,focalLength); 86 | break; 87 | case '-': 88 | if(eyeDist > 0.0f) eyeDist -= 0.0001f; 89 | ChangeRollerParameters(viewAngle,eyeDist,focalLength); 90 | break; 91 | case 'q' : 92 | case ESCAPE : 93 | glutDestroyWindow(window); 94 | exit(0); 95 | } 96 | } 97 | 98 | 99 | void specialKeyboard(int key, int x, int y) 100 | { 101 | switch (key) { 102 | case GLUT_KEY_LEFT: 103 | if(viewAngle > 20.0f) viewAngle -= 1.0f; 104 | ChangeRollerParameters(viewAngle,eyeDist,focalLength); 105 | break; 106 | case GLUT_KEY_RIGHT: 107 | if(viewAngle < 90.0f) viewAngle += 1.0f; 108 | ChangeRollerParameters(viewAngle,eyeDist,focalLength); 109 | break; 110 | case GLUT_KEY_UP: 111 | focalLength += 0.005f; 112 | ChangeRollerParameters(viewAngle,eyeDist,focalLength); 113 | break; 114 | case GLUT_KEY_DOWN: 115 | if(focalLength > 0.01f) focalLength -= 0.005f; 116 | ChangeRollerParameters(viewAngle,eyeDist,focalLength); 117 | break; 118 | } 119 | } 120 | 121 | #endif 122 | 123 | void mouse(int button, int state, int x, int y) 124 | { 125 | } 126 | 127 | 128 | void mousemotion(int x, int y) 129 | { 130 | } 131 | 132 | #if 0 133 | void usage() 134 | { 135 | char msg[800]; 136 | 137 | snprintf(msg,800,"RollerCoaster2000 by Plusplus\nUsage: roller [options]\nOptions:\n\ 138 | -h print this help\n\ 139 | -f select fullscreen mode\n\ 140 | -s select stereoscopic mode (for use with a stereo display device)\n\ 141 | -c {1|5|6} select C.A.V.E. mode(5 or 6 screens, or 1 for normal mode)\n\ 142 | -t select a file containing a track description (default rc2k.trk)\n\ 143 | -x select window width (default 800)\n\ 144 | -y select window height (default 600)\n\ 145 | -i disables intro(skip straight to ride)\n\n"); 146 | #ifdef _WIN32 147 | MessageBoxA(NULL,msg,"RollerCoaster2000",MB_OK); 148 | #else 149 | printf(msg); 150 | #endif 151 | } 152 | #endif 153 | 154 | #if 0 155 | int main(int argc, char* argv[]) 156 | { 157 | int i; 158 | 159 | glutInit(&argc,argv); 160 | i = 1; 161 | while(i 18 | 19 | typedef void *VGL_Surface; 20 | 21 | 22 | GLAPI GLboolean APIENTRY vglInitialize(void); 23 | GLAPI GLboolean APIENTRY vglTerminate(void); 24 | GLAPI void (APIENTRY * vglGetProcAddress(const char *procname)) (); 25 | GLAPI GLboolean APIENTRY vglDestroySurface(VGL_Surface surface); 26 | GLAPI GLboolean APIENTRY vglMakeCurrent(VGL_Surface draw, VGL_Surface read); 27 | GLAPI VGL_Surface APIENTRY vglGetReadSurface(void); 28 | GLAPI VGL_Surface APIENTRY vglGetWriteSurface(void); 29 | 30 | /* SDL bindings */ 31 | GLAPI VGL_Surface APIENTRY vglCreateSurface(GLsizei width, GLsizei height, GLenum format, GLenum type, 32 | GLenum depthStencilType); 33 | GLAPI GLboolean APIENTRY vglSwapBuffers(SDL_Surface * display, VGL_Surface surface); 34 | 35 | 36 | 37 | #endif -------------------------------------------------------------------------------- /lib/.indent.pro: -------------------------------------------------------------------------------- 1 | -kr -l100 -ts4 -c64 -cd64 -cp64 2 | 3 | -------------------------------------------------------------------------------- /lib/bitblt.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Bit transfer engine. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | 17 | static void ClipRectToSize(VPMT_Rect * result, const VPMT_Rect * rect, const VPMT_Size * size) 18 | { 19 | if (rect->origin[0] < 0) { 20 | result->origin[0] = 0; 21 | } else { 22 | result->origin[0] = rect->origin[0]; 23 | } 24 | 25 | if (rect->origin[1] < 0) { 26 | result->origin[1] = 0; 27 | } else { 28 | result->origin[1] = rect->origin[1]; 29 | } 30 | 31 | if (rect->origin[0] + rect->size.width > size->width) { 32 | result->size.width = size->width - result->origin[0]; 33 | } else { 34 | result->size.width = rect->origin[0] + rect->size.width - result->origin[0]; 35 | } 36 | 37 | if (rect->origin[1] + rect->size.height > size->height) { 38 | result->size.height = size->height - result->origin[1]; 39 | } else { 40 | result->size.height = rect->origin[1] + rect->size.height - result->origin[1]; 41 | } 42 | } 43 | 44 | void VPMT_Bitblt(const VPMT_Image2D * dst, const VPMT_Rect * dstRect, const VPMT_Image2D * src, 45 | const GLint * srcPos) 46 | { 47 | VPMT_Rect actualDstRect; 48 | GLsizei pixelSize; 49 | GLsizei dstRowIncrement, srcRowIncrement; 50 | GLsizei dstSpan, srcSpan, copySpan; 51 | GLsizei rowCount; 52 | GLubyte *dstPtr; 53 | const GLubyte *srcPtr; 54 | 55 | /* initially, we do not support any change of pixel types */ 56 | assert(dst->pixelFormat->internalFormat == src->pixelFormat->internalFormat && 57 | dst->pixelFormat->type == src->pixelFormat->type); 58 | 59 | ClipRectToSize(&actualDstRect, dstRect, &dst->size); 60 | 61 | pixelSize = dst->pixelFormat->size; 62 | 63 | dstSpan = dst->size.width * pixelSize; 64 | 65 | dstRowIncrement = dst->pitch; 66 | 67 | srcSpan = src->size.width * pixelSize; 68 | 69 | srcRowIncrement = src->pitch; 70 | 71 | dstPtr = ((GLubyte *) dst->data) + actualDstRect.origin[0] * pixelSize + 72 | actualDstRect.origin[1] * dstRowIncrement; 73 | 74 | srcPtr = srcPos ? 75 | ((const GLubyte *) src->data) + srcPos[0] * pixelSize + srcPos[1] * srcRowIncrement : 76 | ((const GLubyte *) src->data); 77 | 78 | copySpan = actualDstRect.size.width * pixelSize; 79 | 80 | for (rowCount = actualDstRect.size.height; rowCount > 0; 81 | --rowCount, dstPtr += dstRowIncrement, srcPtr += srcRowIncrement) { 82 | GLubyte *dstPtr0 = dstPtr; 83 | const GLubyte *srcPtr0 = srcPtr; 84 | GLsizei columnCount; 85 | 86 | for (columnCount = copySpan; columnCount > 0; --columnCount, ++dstPtr0, ++srcPtr0) { 87 | *dstPtr0 = *srcPtr0; 88 | } 89 | } 90 | } 91 | 92 | /* $Id: bitblt.c 74 2008-11-23 07:25:12Z hmwill $ */ 93 | -------------------------------------------------------------------------------- /lib/command.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** GL command structures 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_COMMAND_H 14 | #define VPMT_COMMAND_H 15 | 16 | #include "context.h" 17 | 18 | typedef enum VPMT_Opcode { 19 | VPMT_OpcodeActiveTexture, 20 | VPMT_OpcodeAlphaFunc, 21 | VPMT_OpcodeBegin, 22 | VPMT_OpcodeBindTexture, 23 | VPMT_OpcodeBitmap, 24 | VPMT_OpcodeBlendFunc, 25 | VPMT_OpcodeClear, 26 | VPMT_OpcodeClearColor, 27 | VPMT_OpcodeClearDepthf, 28 | VPMT_OpcodeClearStencil, 29 | VPMT_OpcodeColor, 30 | VPMT_OpcodeColorMask, 31 | VPMT_OpcodeCopyPixels, 32 | VPMT_OpcodeCullFace, 33 | VPMT_OpcodeDepthFunc, 34 | VPMT_OpcodeDepthMask, 35 | VPMT_OpcodeDepthRangef, 36 | VPMT_OpcodeDrawPixels, 37 | VPMT_OpcodeEnd, 38 | VPMT_OpcodeError, 39 | VPMT_OpcodeFrontFace, 40 | VPMT_OpcodeHint, 41 | VPMT_OpcodeLightfv, 42 | VPMT_OpcodeLightModelfv, 43 | VPMT_OpcodeLineStipple, 44 | VPMT_OpcodeLineWidth, 45 | VPMT_OpcodeListBase, 46 | VPMT_OpcodeLoadIdentity, 47 | VPMT_OpcodeLoadMatrix, 48 | VPMT_OpcodeMaterialfv, 49 | VPMT_OpcodeMatrixMode, 50 | VPMT_OpcodeMultMatrix, 51 | VPMT_OpcodeMultiTexCoord, 52 | VPMT_OpcodeNormal, 53 | VPMT_OpcodePointSize, 54 | VPMT_OpcodePolygonOffset, 55 | VPMT_OpcodePolygonStipple, 56 | VPMT_OpcodePopMatrix, 57 | VPMT_OpcodePushMatrix, 58 | VPMT_OpcodeRasterPos, 59 | VPMT_OpcodeScissor, 60 | VPMT_OpcodeShadeModel, 61 | VPMT_OpcodeStencilFunc, 62 | VPMT_OpcodeStencilMask, 63 | VPMT_OpcodeStencilOp, 64 | VPMT_OpcodeTexEnvfv, 65 | VPMT_OpcodeTexEnvi, 66 | VPMT_OpcodeTexImage2D, 67 | VPMT_OpcodeTexParameteri, 68 | VPMT_OpcodeTexSubImage2D, 69 | VPMT_OpcodeToggle, 70 | VPMT_OpcodeVertex, 71 | VPMT_OpcodeViewport, 72 | 73 | #if GL_EXT_paletted_texture 74 | VPMT_OpcodeColorSubTable, 75 | VPMT_OpcodeColorTable, 76 | #endif 77 | 78 | VPMT_OpcodeInvalid 79 | } VPMT_Opcode; 80 | 81 | typedef struct VPMT_CommandBase { 82 | VPMT_Opcode opcode; 83 | } VPMT_CommandBase; 84 | 85 | typedef struct VPMT_CommandActiveTexture { 86 | VPMT_CommandBase base; 87 | GLenum texture; 88 | } VPMT_CommandActiveTexture; 89 | 90 | typedef struct VPMT_CommandAlphaFunc { 91 | VPMT_CommandBase base; 92 | GLenum func; 93 | GLclampf ref; 94 | } VPMT_CommandAlphaFunc; 95 | 96 | typedef struct VPMT_CommandBegin { 97 | VPMT_CommandBase base; 98 | GLenum mode; 99 | } VPMT_CommandBegin; 100 | 101 | typedef struct VPMT_CommandBindTexture { 102 | VPMT_CommandBase base; 103 | GLenum target; 104 | GLuint texture; 105 | } VPMT_CommandBindTexture; 106 | 107 | typedef struct VPMT_CommandBitmap { 108 | VPMT_CommandBase base; 109 | GLsizei width; 110 | GLsizei height; 111 | GLfloat xorig; 112 | GLfloat yorig; 113 | GLfloat xmove; 114 | GLfloat ymove; 115 | GLubyte *bitmap; 116 | } VPMT_CommandBitmap; 117 | 118 | typedef struct VPMT_CommandBlendFunc { 119 | VPMT_CommandBase base; 120 | GLenum sfactor; 121 | GLenum dfactor; 122 | } VPMT_CommandBlendFunc; 123 | 124 | typedef struct VPMT_CommandClear { 125 | VPMT_CommandBase base; 126 | GLbitfield mask; 127 | } VPMT_CommandClear; 128 | 129 | typedef struct VPMT_CommandClearColor { 130 | VPMT_CommandBase base; 131 | VPMT_Vec4 color; 132 | } VPMT_CommandClearColor; 133 | 134 | typedef struct VPMT_CommandClearDepth { 135 | VPMT_CommandBase base; 136 | GLclampf depth; 137 | } VPMT_CommandClearDepth; 138 | 139 | typedef struct VPMT_CommandClearStencil { 140 | VPMT_CommandBase base; 141 | GLint s; 142 | } VPMT_CommandClearStencil; 143 | 144 | typedef struct VPMT_CommandColor { 145 | VPMT_CommandBase base; 146 | VPMT_Vec4 color; 147 | } VPMT_CommandColor; 148 | 149 | typedef struct VPMT_CommandColorMask { 150 | VPMT_CommandBase base; 151 | VPMT_Vec4b mask; 152 | } VPMT_CommandColorMask; 153 | 154 | typedef struct VPMT_CommandCopyPixels { 155 | VPMT_CommandBase base; 156 | VPMT_Rect rect; 157 | GLenum type; 158 | } VPMT_CommandCopyPixels; 159 | 160 | typedef struct VPMT_CommandCullFace { 161 | VPMT_CommandBase base; 162 | GLenum mode; 163 | } VPMT_CommandCullFace; 164 | 165 | typedef struct VPMT_CommandDepthFunc { 166 | VPMT_CommandBase base; 167 | GLenum func; 168 | } VPMT_CommandDepthFunc; 169 | 170 | typedef struct VPMT_CommandDepthMask { 171 | VPMT_CommandBase base; 172 | GLboolean flag; 173 | } VPMT_CommandDepthMask; 174 | 175 | typedef struct VPMT_CommandDepthRangef { 176 | VPMT_CommandBase base; 177 | GLclampf zNear; 178 | GLclampf zFar; 179 | } VPMT_CommandDepthRangef; 180 | 181 | typedef struct VPMT_CommandDrawPixels { 182 | VPMT_CommandBase base; 183 | VPMT_Image2D *image; 184 | } VPMT_CommandDrawPixels; 185 | 186 | typedef struct VPMT_CommandError { 187 | VPMT_CommandBase base; 188 | GLenum error; 189 | } VPMT_CommandError; 190 | 191 | typedef struct VPMT_CommandFrontFace { 192 | VPMT_CommandBase base; 193 | GLenum mode; 194 | } VPMT_CommandFrontFace; 195 | 196 | typedef struct VPMT_CommandHint { 197 | VPMT_CommandBase base; 198 | GLenum target; 199 | GLenum mode; 200 | } VPMT_CommandHint; 201 | 202 | typedef struct VPMT_CommandLightfv { 203 | VPMT_CommandBase base; 204 | GLenum light; 205 | GLenum pname; 206 | VPMT_Vec4 params; 207 | } VPMT_CommandLightfv; 208 | 209 | typedef struct VPMT_CommandLightModelfv { 210 | VPMT_CommandBase base; 211 | GLenum pname; 212 | VPMT_Vec4 params; 213 | } VPMT_CommandLightModelfv; 214 | 215 | typedef struct VPMT_CommandLineStipple { 216 | VPMT_CommandBase base; 217 | GLint factor; 218 | GLushort pattern; 219 | } VPMT_CommandLineStipple; 220 | 221 | typedef struct VPMT_CommandLineWidth { 222 | VPMT_CommandBase base; 223 | GLfloat width; 224 | } VPMT_CommandLineWidth; 225 | 226 | typedef struct VPMT_CommandListBase { 227 | VPMT_CommandBase base; 228 | GLuint listBase; 229 | } VPMT_CommandListBase; 230 | 231 | typedef struct VPMT_CommandLoadMatrix { 232 | VPMT_CommandBase base; 233 | VPMT_Matrix matrix; 234 | } VPMT_CommandLoadMatrix; 235 | 236 | typedef struct VPMT_CommandMaterialfv { 237 | VPMT_CommandBase base; 238 | GLenum face; 239 | GLenum pname; 240 | VPMT_Vec4 params; 241 | } VPMT_CommandMaterialfv; 242 | 243 | typedef struct VPMT_CommandMatrixMode { 244 | VPMT_CommandBase base; 245 | GLenum mode; 246 | } VPMT_CommandMatrixMode; 247 | 248 | typedef struct VPMT_CommandMultMatrix { 249 | VPMT_CommandBase base; 250 | VPMT_Matrix matrix; 251 | } VPMT_CommandMultMatrix; 252 | 253 | typedef struct VPMT_CommandMultiTexCoord { 254 | VPMT_CommandBase base; 255 | GLenum target; 256 | VPMT_Vec2 coords; 257 | } VPMT_CommandMultiTexCoord; 258 | 259 | typedef struct VPMT_CommandNormal { 260 | VPMT_CommandBase base; 261 | VPMT_Vec3 normal; 262 | } VPMT_CommandNormal; 263 | 264 | typedef struct VPMT_CommandPointSize { 265 | VPMT_CommandBase base; 266 | GLfloat size; 267 | } VPMT_CommandPointSize; 268 | 269 | typedef struct VPMT_CommandPolygonOffset { 270 | VPMT_CommandBase base; 271 | GLfloat factor; 272 | GLfloat units; 273 | } VPMT_CommandPolygonOffset; 274 | 275 | typedef struct VPMT_CommandPolygonStipple { 276 | VPMT_CommandBase base; 277 | VPMT_Pattern mask; 278 | } VPMT_CommandPolygonStipple; 279 | 280 | typedef struct VPMT_CommandRasterPos { 281 | VPMT_CommandBase base; 282 | VPMT_Vec3 position; 283 | } VPMT_CommandRasterPos; 284 | 285 | typedef struct VPMT_CommandScissor { 286 | VPMT_CommandBase base; 287 | VPMT_Rect rect; 288 | } VPMT_CommandScissor; 289 | 290 | typedef struct VPMT_CommandShadeModel { 291 | VPMT_CommandBase base; 292 | GLenum mode; 293 | } VPMT_CommandShadeModel; 294 | 295 | typedef struct VPMT_CommandStencilFunc { 296 | VPMT_CommandBase base; 297 | GLenum func; 298 | GLint ref; 299 | GLuint mask; 300 | } VPMT_CommandStencilFunc; 301 | 302 | typedef struct VPMT_CommandStencilMask { 303 | VPMT_CommandBase base; 304 | GLuint mask; 305 | } VPMT_CommandStencilMask; 306 | 307 | typedef struct VPMT_CommandStencilOp { 308 | VPMT_CommandBase base; 309 | GLenum fail; 310 | GLenum zfail; 311 | GLenum zpass; 312 | } VPMT_CommandStencilOp; 313 | 314 | typedef struct VPMT_CommandTexEnvfv { 315 | VPMT_CommandBase base; 316 | GLenum target; 317 | GLenum pname; 318 | VPMT_Vec4 params; 319 | } VPMT_CommandTexEnvfv; 320 | 321 | typedef struct VPMT_CommandTexEnvi { 322 | VPMT_CommandBase base; 323 | GLenum target; 324 | GLenum pname; 325 | GLint param; 326 | } VPMT_CommandTexEnvi; 327 | 328 | typedef struct VPMT_CommandTexImage2D { 329 | VPMT_CommandBase base; 330 | GLenum target; 331 | GLint level; 332 | VPMT_Image2D *image; 333 | } VPMT_CommandTexImage2D; 334 | 335 | typedef struct VPMT_CommandTexParameteri { 336 | VPMT_CommandBase base; 337 | GLenum target; 338 | GLenum pname; 339 | GLint param; 340 | } VPMT_CommandTexParameteri; 341 | 342 | typedef struct VPMT_CommandTexSubImage2D { 343 | VPMT_CommandBase base; 344 | GLenum target; 345 | GLint level; 346 | VPMT_Image2D *image; 347 | GLint xoffset; 348 | GLint yoffset; 349 | } VPMT_CommandTexSubImage2D; 350 | 351 | typedef struct VPMT_CommandToggle { 352 | VPMT_CommandBase base; 353 | GLenum cap; 354 | GLboolean enable; 355 | } VPMT_CommandToggle; 356 | 357 | typedef struct VPMT_CommandVertex { 358 | VPMT_CommandBase base; 359 | VPMT_Vec3 vertex; 360 | } VPMT_CommandVertex; 361 | 362 | typedef struct VPMT_CommandViewport { 363 | VPMT_CommandBase base; 364 | VPMT_Rect rect; 365 | } VPMT_CommandViewport; 366 | 367 | #if GL_EXT_paletted_texture 368 | 369 | typedef struct VPMT_CommandColorSubTable { 370 | VPMT_CommandBase base; 371 | GLenum target; 372 | GLsizei start; 373 | VPMT_Image1D *palette; 374 | } VPMT_CommandColorSubTable; 375 | 376 | typedef struct VPMT_CommandColorTable { 377 | VPMT_CommandBase base; 378 | GLenum target; 379 | VPMT_Image1D *palette; 380 | } VPMT_CommandColorTable; 381 | 382 | #endif 383 | 384 | typedef union VPMT_Command { 385 | VPMT_CommandBase base; 386 | VPMT_CommandActiveTexture activeTexture; 387 | VPMT_CommandAlphaFunc alphaFunc; 388 | VPMT_CommandBegin begin; 389 | VPMT_CommandBindTexture bindTexture; 390 | VPMT_CommandBitmap bitmap; 391 | VPMT_CommandBlendFunc blendFunc; 392 | VPMT_CommandClear clear; 393 | VPMT_CommandClearColor clearColor; 394 | VPMT_CommandClearDepth clearDepth; 395 | VPMT_CommandClearStencil clearStencil; 396 | VPMT_CommandColor color; 397 | VPMT_CommandColorMask colorMask; 398 | VPMT_CommandCopyPixels copyPixels; 399 | VPMT_CommandCullFace cullFace; 400 | VPMT_CommandDepthFunc depthFunc; 401 | VPMT_CommandDepthMask depthMask; 402 | VPMT_CommandDepthRangef depthRangef; 403 | VPMT_CommandDrawPixels drawPixels; 404 | VPMT_CommandError error; 405 | VPMT_CommandFrontFace frontFace; 406 | VPMT_CommandHint hint; 407 | VPMT_CommandLightfv lighfv; 408 | VPMT_CommandLightModelfv lightModelfv; 409 | VPMT_CommandLineStipple lineStipple; 410 | VPMT_CommandLineWidth lineWidth; 411 | VPMT_CommandListBase listBase; 412 | VPMT_CommandLoadMatrix loadMatrix; 413 | VPMT_CommandMaterialfv materialfv; 414 | VPMT_CommandMatrixMode matrixMode; 415 | VPMT_CommandMultMatrix multMatrix; 416 | VPMT_CommandMultiTexCoord multiTexCoord; 417 | VPMT_CommandNormal normal; 418 | VPMT_CommandPointSize pointSize; 419 | VPMT_CommandPolygonOffset polygonOffset; 420 | VPMT_CommandPolygonStipple polygonStipple; 421 | VPMT_CommandRasterPos rasterPos; 422 | VPMT_CommandScissor scissor; 423 | VPMT_CommandShadeModel shadeModel; 424 | VPMT_CommandStencilFunc stencilFunc; 425 | VPMT_CommandStencilMask stencilMask; 426 | VPMT_CommandStencilOp stencilOp; 427 | VPMT_CommandTexEnvfv texEnvfv; 428 | VPMT_CommandTexEnvi texEnvi; 429 | VPMT_CommandTexImage2D texImage2D; 430 | VPMT_CommandTexParameteri texParameteri; 431 | VPMT_CommandTexSubImage2D texSubImage2D; 432 | VPMT_CommandToggle toggle; 433 | VPMT_CommandVertex vertex; 434 | VPMT_CommandViewport viewport; 435 | 436 | #if GL_EXT_paletted_texture 437 | VPMT_CommandColorSubTable colorSubTable; 438 | VPMT_CommandColorTable colorTable; 439 | #endif 440 | 441 | } VPMT_Command; 442 | 443 | typedef struct VPMT_CommandBuffer { 444 | struct VPMT_CommandBuffer *next; /* next buffer belonging to list */ 445 | GLsizei used; /* amount of command storage used */ 446 | GLsizei total; /* total command storage in buffer */ 447 | GLubyte *commands; /* actual command array */ 448 | } VPMT_CommandBuffer; 449 | 450 | void VPMT_CommandBufferDispose(VPMT_CommandBuffer * commands); 451 | 452 | #endif 453 | 454 | /* $Id: command.h 74 2008-11-23 07:25:12Z hmwill $ */ 455 | -------------------------------------------------------------------------------- /lib/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Common File Includes 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_COMMON_H 14 | #define VPMT_COMMON_H 15 | 16 | #include "platform.h" 17 | #include "library.h" 18 | #include "config.h" 19 | 20 | #endif 21 | 22 | /* $Id: common.h 74 2008-11-23 07:25:12Z hmwill $ */ 23 | -------------------------------------------------------------------------------- /lib/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Configuration parameters 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_CONFIG_H 14 | #define VPMT_CONFIG_H 15 | 16 | /* 17 | ** ------------------------------------------------------------------------- 18 | ** Version information 19 | ** ------------------------------------------------------------------------- 20 | */ 21 | 22 | #define VPMT_VENDOR "Vincent Pervasive Media Technologies, LLC." 23 | #define VPMT_RENDERER "Vincent SC 1.0 Rendering Library" 24 | #define VPMT_VERSION "OpenGL ES-SC 1.0" 25 | 26 | #define VPMT_SC_RELAX /* relax checks to pass conformance test */ 27 | 28 | /* 29 | ** ------------------------------------------------------------------------- 30 | ** Implementation limits 31 | ** ------------------------------------------------------------------------- 32 | */ 33 | 34 | #define VPMT_MAX_VIEWPORT_WIDTH 2048 /* max. viewport width */ 35 | #define VPMT_MAX_VIEWPORT_HEIGHT 2048 /* max. viewport height */ 36 | #define VPMT_VIEWPORT_COORD_BITS 12 /* number of bits to index */ 37 | 38 | #define VPMT_MAX_TEX_UNITS 2 /* max. number of tex units */ 39 | #define VPMT_MAX_LIGHTS 2 /* max. number of lights */ 40 | #define VPMT_MAX_TEXTURES 64 /* max. number of textures */ 41 | #define VPMT_MAX_MIPMAP_LEVEL 11 /* max. number of mipmaps */ 42 | #define VPMT_MAX_TEXTURE_SIZE (1 << (VPMT_MAX_MIPMAP_LEVEL-1)) 43 | 44 | #define VPMT_MAX_ELEMENTS_INDICES 16 /* arbitrary */ 45 | #define VPMT_MAX_ELEMENTS_VERTICES 16 /* arbitrary */ 46 | 47 | #define VPMT_MODELVIEW_STACK_DEPTH 32 /* max. matrix stack depth */ 48 | #define VPMT_PROJECTION_STACK_DEPTH 2 /* max. matrix stack depth */ 49 | #define VPMT_SUBPIXEL_BITS 4 /* log2 sub-divisions of pixel */ 50 | 51 | #define VPMT_MAX_POINT_SIZE 16.0f /* maximum point size */ 52 | #define VPMT_SMOOTH_POINT_SIZE_GRANULARITY (1.0f/(1 << VPMT_SUBPIXEL_BITS)) /* granularity */ 53 | #define VPMT_MIN_SMOOTH_POINT_SIZE VPMT_SMOOTH_POINT_SIZE_GRANULARITY /* minimum smooth point size */ 54 | #define VPMT_MAX_SMOOTH_POINT_SIZE VPMT_MAX_POINT_SIZE /* maximum smooth point size */ 55 | 56 | #define VPMT_MAX_LINE_WIDTH 16.0f /* maximum line width */ 57 | #define VPMT_SMOOTH_LINE_WIDTH_GRANULARITY 1.0f /* granularity */ 58 | #define VPMT_MIN_SMOOTH_LINE_WIDTH VPMT_SMOOTH_LINE_WIDTH_GRANULARITY /* minimum smooth line width */ 59 | #define VPMT_MAX_SMOOTH_LINE_WIDTH VPMT_MAX_LINE_WIDTH /* maximum smooth line width */ 60 | 61 | /* 62 | ** ------------------------------------------------------------------------- 63 | ** Other configuration parameters 64 | ** ------------------------------------------------------------------------- 65 | */ 66 | 67 | #define VPMT_HASH_SIZE 257 /* Hash table size */ 68 | #define VPMT_PACK_ALIGNMENT 4 /* internal alignment */ 69 | #define VPMT_COMMAND_BUFFER_SIZE 512 /* Display list increment */ 70 | #define VPMT_MAX_RENDER_BUFFERS 2 /* maximum number of buffers attached to framebuffer */ 71 | 72 | #define VPMT_FUNCTION_CACHE_ENRIES 128 /* number of cached functions */ 73 | #define VPMT_FUNCTION_CACHE_SIZE 65536 /* code cache size */ 74 | #define VPMT_FUNCTION_STATE_SIZE_INIT 1024 /* initial state buffer */ 75 | #define VPMT_FUNCTION_CODE_SIZE_INIT 4096 /* initial code buffer */ 76 | 77 | /* 78 | ** ------------------------------------------------------------------------- 79 | ** Platform constants 80 | ** ------------------------------------------------------------------------- 81 | */ 82 | 83 | #define VPMT_LITTLE_ENDIAN 1 /* low byte first */ 84 | #define VPMT_BITS_PER_BYTE 8 /* bits per byte */ 85 | #define VPMT_FLOAT_MASTISSA_BITS 23 /* bits per mantissa */ 86 | 87 | #define VPMT_BYTE_MIN SCHAR_MIN /* minimum value for GLbyte */ 88 | #define VPMT_BYTE_MAX SCHAR_MAX /* maximum value for GLbyte */ 89 | #define VPMT_UBYTE_MAX UCHAR_MAX /* maximum value for GLubyte */ 90 | #define VPMT_SHORT_MIN SHRT_MIN /* minimum value for GLshort */ 91 | #define VPMT_SHORT_MAX SHRT_MAX /* maximum value for GLshort */ 92 | #define VPMT_USHORT_MAX USHRT_MAX /* maximum value for GLushort */ 93 | #define VPMT_INT_MIN INT_MIN /* minimum value for GLint */ 94 | #define VPMT_INT_MAX INT_MAX /* maximum value for GLint */ 95 | #define VPMT_UINT_MAX UINT_MAX /* maximum value for GLuint */ 96 | 97 | #endif 98 | 99 | /* $Id: config.h 74 2008-11-23 07:25:12Z hmwill $ */ 100 | -------------------------------------------------------------------------------- /lib/dispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** GL Function Dispatch Table 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_DISPATCH_H 14 | #define VPMT_DISPATCH_H 15 | 16 | typedef struct VPMT_Dispatch { 17 | void (*ActiveTexture) (VPMT_Context * context, GLenum texture); 18 | void (*AlphaFunc) (VPMT_Context * context, GLenum func, GLclampf ref); 19 | void (*Begin) (VPMT_Context * context, GLenum mode); 20 | void (*BindTexture) (VPMT_Context * context, GLenum target, GLuint texture); 21 | void (*Bitmap) (VPMT_Context * context, GLsizei width, GLsizei height, GLfloat xorig, 22 | GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); 23 | void (*BlendFunc) (VPMT_Context * context, GLenum sfactor, GLenum dfactor); 24 | void (*CallLists) (VPMT_Context * context, GLsizei n, GLenum type, const GLvoid * lists); 25 | void (*Clear) (VPMT_Context * context, GLbitfield mask); 26 | void (*ClearColor) (VPMT_Context * context, GLclampf red, GLclampf green, GLclampf blue, 27 | GLclampf alpha); 28 | void (*ClearDepthf) (VPMT_Context * context, GLclampf depth); 29 | void (*ClearStencil) (VPMT_Context * context, GLint s); 30 | void (*ClientActiveTexture) (VPMT_Context * context, GLenum texture); 31 | void (*Color4f) (VPMT_Context * context, GLfloat red, GLfloat green, GLfloat blue, 32 | GLfloat alpha); 33 | void (*Color4fv) (VPMT_Context * context, const GLfloat * v); 34 | void (*Color4ub) (VPMT_Context * context, GLubyte red, GLubyte green, GLubyte blue, 35 | GLubyte alpha); 36 | void (*ColorMask) (VPMT_Context * context, GLboolean red, GLboolean green, GLboolean blue, 37 | GLboolean alpha); 38 | void (*ColorPointer) (VPMT_Context * context, GLint size, GLenum type, GLsizei stride, 39 | const GLvoid * pointer); 40 | void (*CopyPixels) (VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height, 41 | GLenum type); 42 | void (*CullFace) (VPMT_Context * context, GLenum mode); 43 | void (*DeleteLists) (VPMT_Context * context, GLuint list, GLsizei range); 44 | void (*DeleteTextures) (VPMT_Context * context, GLsizei n, const GLuint *textures); 45 | void (*DepthFunc) (VPMT_Context * context, GLenum func); 46 | void (*DepthMask) (VPMT_Context * context, GLboolean flag); 47 | void (*DepthRangef) (VPMT_Context * context, GLclampf zNear, GLclampf zFar); 48 | void (*Disable) (VPMT_Context * context, GLenum cap); 49 | void (*DisableClientState) (VPMT_Context * context, GLenum array); 50 | void (*DrawArrays) (VPMT_Context * context, GLenum mode, GLint first, GLsizei count); 51 | void (*DrawElements) (VPMT_Context * context, GLenum mode, GLsizei count, GLenum type, 52 | const GLvoid * indices); 53 | void (*DrawPixels) (VPMT_Context * context, GLsizei width, GLsizei height, GLenum format, 54 | GLenum type, const GLvoid * pixels); 55 | void (*Enable) (VPMT_Context * context, GLenum cap); 56 | void (*EnableClientState) (VPMT_Context * context, GLenum array); 57 | void (*End) (VPMT_Context * context); 58 | void (*EndList) (VPMT_Context * context); 59 | void (*Finish) (VPMT_Context * context); 60 | void (*Flush) (VPMT_Context * context); 61 | void (*FrontFace) (VPMT_Context * context, GLenum mode); 62 | void (*Frustumf) (VPMT_Context * context, GLfloat left, GLfloat right, GLfloat bottom, 63 | GLfloat top, GLfloat zNear, GLfloat zFar); 64 | GLuint(*GenLists) (VPMT_Context * context, GLsizei range); 65 | void (*GenTextures) (VPMT_Context * context, GLsizei n, GLuint * textures); 66 | void (*GetBooleanv) (VPMT_Context * context, GLenum pname, GLboolean * params); 67 | GLenum(*GetError) (VPMT_Context * context); 68 | void (*GetFloatv) (VPMT_Context * context, GLenum pname, GLfloat * params); 69 | void (*GetIntegerv) (VPMT_Context * context, GLenum pname, GLint * params); 70 | void (*GetLightfv) (VPMT_Context * context, GLenum light, GLenum pname, GLfloat * params); 71 | void (*GetMaterialfv) (VPMT_Context * context, GLenum face, GLenum pname, GLfloat * params); 72 | void (*GetPointerv) (VPMT_Context * context, GLenum pname, GLvoid * *params); 73 | void (*GetPolygonStipple) (VPMT_Context * context, GLubyte * mask); 74 | const GLubyte *(*GetString) (VPMT_Context * context, GLenum name); 75 | void (*GetTexEnvfv) (VPMT_Context * context, GLenum target, GLenum pname, GLfloat * params); 76 | void (*GetTexEnviv) (VPMT_Context * context, GLenum target, GLenum pname, GLint * params); 77 | void (*GetTexParameteriv) (VPMT_Context * context, GLenum target, GLenum pname, GLint * params); 78 | void (*Hint) (VPMT_Context * context, GLenum target, GLenum mode); 79 | GLboolean(*IsEnabled) (VPMT_Context * context, GLenum cap); 80 | void (*Lightfv) (VPMT_Context * context, GLenum light, GLenum pname, const GLfloat * params); 81 | void (*LightModelf) (VPMT_Context * context, GLenum pname, GLfloat param); 82 | void (*LightModelfv) (VPMT_Context * context, GLenum pname, const GLfloat * params); 83 | void (*LineStipple) (VPMT_Context * context, GLint factor, GLushort pattern); 84 | void (*LineWidth) (VPMT_Context * context, GLfloat width); 85 | void (*ListBase) (VPMT_Context * context, GLuint base); 86 | void (*LoadIdentity) (VPMT_Context * context); 87 | void (*LoadMatrixf) (VPMT_Context * context, const GLfloat * m); 88 | void (*Materialf) (VPMT_Context * context, GLenum face, GLenum pname, GLfloat param); 89 | void (*Materialfv) (VPMT_Context * context, GLenum face, GLenum pname, const GLfloat * params); 90 | void (*MatrixMode) (VPMT_Context * context, GLenum mode); 91 | void (*MultMatrixf) (VPMT_Context * context, const GLfloat * m); 92 | void (*MultiTexCoord2f) (VPMT_Context * context, GLenum target, GLfloat s, GLfloat t); 93 | void (*NewList) (VPMT_Context * context, GLuint list, GLenum mode); 94 | void (*Normal3f) (VPMT_Context * context, GLfloat nx, GLfloat ny, GLfloat nz); 95 | void (*Normal3fv) (VPMT_Context * context, const GLfloat * v); 96 | void (*NormalPointer) (VPMT_Context * context, GLenum type, GLsizei stride, 97 | const GLvoid * pointer); 98 | void (*Orthof) (VPMT_Context * context, GLfloat left, GLfloat right, GLfloat bottom, 99 | GLfloat top, GLfloat zNear, GLfloat zFar); 100 | void (*PixelStorei) (VPMT_Context * context, GLenum pname, GLint param); 101 | void (*PointSize) (VPMT_Context * context, GLfloat size); 102 | void (*PolygonOffset) (VPMT_Context * context, GLfloat factor, GLfloat units); 103 | void (*PolygonStipple) (VPMT_Context * context, const GLubyte * mask); 104 | void (*PopMatrix) (VPMT_Context * context); 105 | void (*PushMatrix) (VPMT_Context * context); 106 | void (*RasterPos3f) (VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 107 | void (*ReadPixels) (VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height, 108 | GLenum format, GLenum type, GLvoid * pixels); 109 | void (*Rotatef) (VPMT_Context * context, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); 110 | void (*Scalef) (VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 111 | void (*Scissor) (VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height); 112 | void (*ShadeModel) (VPMT_Context * context, GLenum mode); 113 | void (*StencilFunc) (VPMT_Context * context, GLenum func, GLint ref, GLuint mask); 114 | void (*StencilMask) (VPMT_Context * context, GLuint mask); 115 | void (*StencilOp) (VPMT_Context * context, GLenum fail, GLenum zfail, GLenum zpass); 116 | void (*TexCoordPointer) (VPMT_Context * context, GLint size, GLenum type, GLsizei stride, 117 | const GLvoid * pointer); 118 | void (*TexEnvfv) (VPMT_Context * context, GLenum target, GLenum pname, const GLfloat * params); 119 | void (*TexEnvi) (VPMT_Context * context, GLenum target, GLenum pname, GLint param); 120 | void (*TexImage2D) (VPMT_Context * context, GLenum target, GLint level, GLint internalformat, 121 | GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, 122 | const GLvoid * pixels); 123 | void (*TexParameteri) (VPMT_Context * context, GLenum target, GLenum pname, GLint param); 124 | void (*TexSubImage2D) (VPMT_Context * context, GLenum target, GLint level, GLint xoffset, 125 | GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, 126 | const GLvoid * pixels); 127 | void (*Translatef) (VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 128 | void (*Vertex2f) (VPMT_Context * context, GLfloat x, GLfloat y); 129 | void (*Vertex2fv) (VPMT_Context * context, const GLfloat * v); 130 | void (*Vertex3f) (VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 131 | void (*Vertex3fv) (VPMT_Context * context, const GLfloat * v); 132 | void (*VertexPointer) (VPMT_Context * context, GLint size, GLenum type, GLsizei stride, 133 | const GLvoid * pointer); 134 | void (*Viewport) (VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height); 135 | 136 | #if GL_EXT_paletted_texture 137 | void (*ColorSubTable) (VPMT_Context * context, GLenum target, GLsizei start, GLsizei count, 138 | GLenum format, GLenum type, const GLvoid * table); 139 | void (*ColorTable) (VPMT_Context * context, GLenum target, GLenum internalformat, GLsizei width, 140 | GLenum format, GLenum type, const GLvoid * table); 141 | void (*GetColorTable) (VPMT_Context * context, GLenum target, GLenum format, GLenum type, 142 | GLvoid * table); 143 | void (*GetColorTableParameteriv) (VPMT_Context * context, GLenum target, GLenum pname, 144 | GLint * params); 145 | #endif 146 | } VPMT_Dispatch; 147 | 148 | extern struct VPMT_Dispatch VPMT_DispatchExecute, VPMT_DispatchRecord; 149 | 150 | #endif 151 | 152 | /* $Id: dispatch.h 74 2008-11-23 07:25:12Z hmwill $ */ 153 | -------------------------------------------------------------------------------- /lib/exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** GL Execution Functions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_EXEC_H 14 | #define VPMT_EXEC_H 15 | 16 | void VPMT_ExecActiveTexture(VPMT_Context * context, GLenum texture); 17 | void VPMT_ExecAlphaFunc(VPMT_Context * context, GLenum func, GLclampf ref); 18 | void VPMT_ExecBegin(VPMT_Context * context, GLenum mode); 19 | void VPMT_ExecBindTexture(VPMT_Context * context, GLenum target, GLuint name); 20 | void VPMT_ExecBitmap(VPMT_Context * context, GLsizei width, GLsizei height, GLfloat xorig, 21 | GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); 22 | void VPMT_ExecBlendFunc(VPMT_Context * context, GLenum sfactor, GLenum dfactor); 23 | void VPMT_ExecCallLists(VPMT_Context * context, GLsizei n, GLenum type, const GLvoid * lists); 24 | void VPMT_ExecClear(VPMT_Context * context, GLbitfield mask); 25 | void VPMT_ExecClearColor(VPMT_Context * context, GLclampf red, GLclampf green, GLclampf blue, 26 | GLclampf alpha); 27 | void VPMT_ExecClearDepthf(VPMT_Context * context, GLclampf depth); 28 | void VPMT_ExecClearStencil(VPMT_Context * context, GLint s); 29 | void VPMT_ExecClientActiveTexture(VPMT_Context * context, GLenum texture); 30 | void VPMT_ExecColor4f(VPMT_Context * context, GLfloat red, GLfloat green, GLfloat blue, 31 | GLfloat alpha); 32 | void VPMT_ExecColor4fv(VPMT_Context * context, const GLfloat * v); 33 | void VPMT_ExecColor4ub(VPMT_Context * context, GLubyte red, GLubyte green, GLubyte blue, 34 | GLubyte alpha); 35 | void VPMT_ExecColorMask(VPMT_Context * context, GLboolean red, GLboolean green, GLboolean blue, 36 | GLboolean alpha); 37 | void VPMT_ExecColorPointer(VPMT_Context * context, GLint size, GLenum type, GLsizei stride, 38 | const GLvoid * pointer); 39 | void VPMT_ExecCopyPixels(VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height, 40 | GLenum type); 41 | void VPMT_ExecCullFace(VPMT_Context * context, GLenum mode); 42 | void VPMT_ExecDepthFunc(VPMT_Context * context, GLenum func); 43 | void VPMT_ExecDepthMask(VPMT_Context * context, GLboolean flag); 44 | void VPMT_ExecDepthRangef(VPMT_Context * context, GLclampf zNear, GLclampf zFar); 45 | void VPMT_ExecDisable(VPMT_Context * context, GLenum cap); 46 | void VPMT_ExecDisableClientState(VPMT_Context * context, GLenum array); 47 | void VPMT_ExecDrawArrays(VPMT_Context * context, GLenum mode, GLint first, GLsizei count); 48 | void VPMT_ExecDrawElements(VPMT_Context * context, GLenum mode, GLsizei count, GLenum type, 49 | const GLvoid * indices); 50 | void VPMT_ExecDrawPixels(VPMT_Context * context, GLsizei width, GLsizei height, GLenum format, 51 | GLenum type, const GLvoid * pixels); 52 | void VPMT_ExecEnable(VPMT_Context * context, GLenum cap); 53 | void VPMT_ExecEnableClientState(VPMT_Context * context, GLenum array); 54 | void VPMT_ExecEnd(VPMT_Context * context); 55 | void VPMT_ExecEndList(VPMT_Context * context); 56 | void VPMT_ExecFinish(VPMT_Context * context); 57 | void VPMT_ExecFlush(VPMT_Context * context); 58 | void VPMT_ExecFrontFace(VPMT_Context * context, GLenum mode); 59 | void VPMT_ExecFrustumf(VPMT_Context * context, GLfloat left, GLfloat right, GLfloat bottom, 60 | GLfloat top, GLfloat zNear, GLfloat zFar); 61 | GLuint VPMT_ExecGenLists(VPMT_Context * context, GLsizei range); 62 | void VPMT_ExecGenTextures(VPMT_Context * context, GLsizei n, GLuint * textures); 63 | void VPMT_ExecGetBooleanv(VPMT_Context * context, GLenum pname, GLboolean * params); 64 | GLenum VPMT_ExecGetError(VPMT_Context * context); 65 | void VPMT_ExecGetFloatv(VPMT_Context * context, GLenum pname, GLfloat * params); 66 | void VPMT_ExecGetIntegerv(VPMT_Context * context, GLenum pname, GLint * params); 67 | void VPMT_ExecGetLightfv(VPMT_Context * context, GLenum light, GLenum pname, GLfloat * params); 68 | void VPMT_ExecGetMaterialfv(VPMT_Context * context, GLenum face, GLenum pname, GLfloat * params); 69 | void VPMT_ExecGetPointerv(VPMT_Context * context, GLenum pname, GLvoid ** params); 70 | void VPMT_ExecGetPolygonStipple(VPMT_Context * context, GLubyte * mask); 71 | const GLubyte *VPMT_ExecGetString(VPMT_Context * context, GLenum name); 72 | void VPMT_ExecGetTexEnvfv(VPMT_Context * context, GLenum target, GLenum pname, GLfloat * params); 73 | void VPMT_ExecGetTexEnviv(VPMT_Context * context, GLenum target, GLenum pname, GLint * params); 74 | void VPMT_ExecGetTexParameteriv(VPMT_Context * context, GLenum target, GLenum pname, 75 | GLint * params); 76 | void VPMT_ExecHint(VPMT_Context * context, GLenum target, GLenum mode); 77 | GLboolean VPMT_ExecIsEnabled(VPMT_Context * context, GLenum cap); 78 | void VPMT_ExecLightfv(VPMT_Context * context, GLenum light, GLenum pname, const GLfloat * params); 79 | void VPMT_ExecLightModelf(VPMT_Context * context, GLenum pname, GLfloat param); 80 | void VPMT_ExecLightModelfv(VPMT_Context * context, GLenum pname, const GLfloat * params); 81 | void VPMT_ExecLineStipple(VPMT_Context * context, GLint factor, GLushort pattern); 82 | void VPMT_ExecLineWidth(VPMT_Context * context, GLfloat width); 83 | void VPMT_ExecListBase(VPMT_Context * context, GLuint base); 84 | void VPMT_ExecLoadIdentity(VPMT_Context * context); 85 | void VPMT_ExecLoadMatrixf(VPMT_Context * context, const GLfloat * m); 86 | void VPMT_ExecMaterialf(VPMT_Context * context, GLenum face, GLenum pname, GLfloat param); 87 | void VPMT_ExecMaterialfv(VPMT_Context * context, GLenum face, GLenum pname, const GLfloat * params); 88 | void VPMT_ExecMatrixMode(VPMT_Context * context, GLenum mode); 89 | void VPMT_ExecMultiTexCoord2f(VPMT_Context * context, GLenum target, GLfloat s, GLfloat t); 90 | void VPMT_ExecMultMatrixf(VPMT_Context * context, const GLfloat * m); 91 | void VPMT_ExecNewList(VPMT_Context * context, GLuint list, GLenum mode); 92 | void VPMT_ExecNormal3f(VPMT_Context * context, GLfloat nx, GLfloat ny, GLfloat nz); 93 | void VPMT_ExecNormal3fv(VPMT_Context * context, const GLfloat * v); 94 | void VPMT_ExecNormalPointer(VPMT_Context * context, GLenum type, GLsizei stride, 95 | const GLvoid * pointer); 96 | void VPMT_ExecOrthof(VPMT_Context * context, GLfloat left, GLfloat right, GLfloat bottom, 97 | GLfloat top, GLfloat zNear, GLfloat zFar); 98 | void VPMT_ExecPixelStorei(VPMT_Context * context, GLenum pname, GLint param); 99 | void VPMT_ExecPointSize(VPMT_Context * context, GLfloat size); 100 | void VPMT_ExecPolygonOffset(VPMT_Context * context, GLfloat factor, GLfloat units); 101 | void VPMT_ExecPolygonStipple(VPMT_Context * context, const GLubyte * mask); 102 | void VPMT_ExecPopMatrix(VPMT_Context * context); 103 | void VPMT_ExecPushMatrix(VPMT_Context * context); 104 | void VPMT_ExecRasterPos3f(VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 105 | void VPMT_ExecReadPixels(VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height, 106 | GLenum format, GLenum type, GLvoid * pixels); 107 | void VPMT_ExecRotatef(VPMT_Context * context, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); 108 | void VPMT_ExecScalef(VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 109 | void VPMT_ExecScissor(VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height); 110 | void VPMT_ExecShadeModel(VPMT_Context * context, GLenum mode); 111 | void VPMT_ExecStencilFunc(VPMT_Context * context, GLenum func, GLint ref, GLuint mask); 112 | void VPMT_ExecStencilMask(VPMT_Context * context, GLuint mask); 113 | void VPMT_ExecStencilOp(VPMT_Context * context, GLenum fail, GLenum zfail, GLenum zpass); 114 | void VPMT_ExecTexCoordPointer(VPMT_Context * context, GLint size, GLenum type, GLsizei stride, 115 | const GLvoid * pointer); 116 | void VPMT_ExecTexEnvfv(VPMT_Context * context, GLenum target, GLenum pname, const GLfloat * params); 117 | void VPMT_ExecTexEnvi(VPMT_Context * context, GLenum target, GLenum pname, GLint param); 118 | void VPMT_ExecTexImage2D(VPMT_Context * context, GLenum target, GLint level, GLint internalformat, 119 | GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, 120 | const GLvoid * pixels); 121 | void VPMT_ExecTexParameteri(VPMT_Context * context, GLenum target, GLenum pname, GLint param); 122 | void VPMT_ExecTexSubImage2D(VPMT_Context * context, GLenum target, GLint level, GLint xoffset, 123 | GLint yoffset, GLsizei width, GLsizei height, GLenum format, 124 | GLenum type, const GLvoid * pixels); 125 | void VPMT_ExecTranslatef(VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 126 | void VPMT_ExecVertex2f(VPMT_Context * context, GLfloat x, GLfloat y); 127 | void VPMT_ExecVertex2fv(VPMT_Context * context, const GLfloat * v); 128 | void VPMT_ExecVertex3f(VPMT_Context * context, GLfloat x, GLfloat y, GLfloat z); 129 | void VPMT_ExecVertex3fv(VPMT_Context * context, const GLfloat * v); 130 | void VPMT_ExecVertexPointer(VPMT_Context * context, GLint size, GLenum type, GLsizei stride, 131 | const GLvoid * pointer); 132 | void VPMT_ExecViewport(VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height); 133 | 134 | /* execution only */ 135 | void VPMT_ExecDrawPixelsImage(VPMT_Context * context, const VPMT_Image2D * image); 136 | void VPMT_ExecTexImage2DImage(VPMT_Context * context, GLenum target, GLint level, 137 | GLint internalformat, const VPMT_Image2D * srcImage); 138 | void VPMT_ExecTexSubImage2DImage(VPMT_Context * context, GLenum target, GLint level, GLint xoffset, 139 | GLint yoffset, const VPMT_Image2D * srcImage); 140 | 141 | #if GL_EXT_paletted_texture 142 | void VPMT_ExecColorSubTable(VPMT_Context * context, GLenum target, GLsizei start, GLsizei count, 143 | GLenum format, GLenum type, const GLvoid * table); 144 | void VPMT_ExecColorTable(VPMT_Context * context, GLenum target, GLenum internalformat, 145 | GLsizei width, GLenum format, GLenum type, const GLvoid * table); 146 | void VPMT_ExecGetColorTable(VPMT_Context * context, GLenum target, GLenum format, GLenum type, 147 | GLvoid * table); 148 | void VPMT_ExecGetColorTableParameteriv(VPMT_Context * context, GLenum target, GLenum pname, 149 | GLint * params); 150 | 151 | /* execution only */ 152 | void VPMT_ExecColorSubTableImage(VPMT_Context * context, GLenum target, GLsizei start, 153 | const VPMT_Image1D * srcImage); 154 | void VPMT_ExecColorTableImage(VPMT_Context * context, GLenum target, const VPMT_Image1D * srcImage); 155 | 156 | #endif 157 | 158 | void VPMT_ExecDeleteLists (VPMT_Context * context, GLuint list, GLsizei range); 159 | void VPMT_ExecDeleteTextures (VPMT_Context * context, GLsizei n, const GLuint *textures); 160 | 161 | #endif 162 | 163 | /* $Id: exec.h 74 2008-11-23 07:25:12Z hmwill $ */ 164 | -------------------------------------------------------------------------------- /lib/frag.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Fragment processing functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "exec.h" 17 | 18 | /* 19 | ** ------------------------------------------------------------------------- 20 | ** Exported API entry points 21 | ** ------------------------------------------------------------------------- 22 | */ 23 | 24 | void VPMT_ExecAlphaFunc(VPMT_Context * context, GLenum func, GLclampf ref) 25 | { 26 | VPMT_NOT_RENDERING(context); 27 | 28 | switch (func) { 29 | case GL_LEQUAL: 30 | case GL_ALWAYS: 31 | context->alphaFunc = func; 32 | break; 33 | 34 | default: 35 | VPMT_INVALID_ENUM(context); 36 | return; 37 | } 38 | 39 | context->alphaRef = (ref < 0.0f) ? 0.0f : (ref > 1.0f) ? 1.0f : ref; 40 | context->alphaRefub = (GLubyte) (context->alphaRef * 0xff + 0.5f); 41 | } 42 | 43 | void VPMT_ExecBlendFunc(VPMT_Context * context, GLenum sfactor, GLenum dfactor) 44 | { 45 | VPMT_NOT_RENDERING(context); 46 | 47 | if ((sfactor == GL_SRC_ALPHA && dfactor == GL_ONE_MINUS_SRC_ALPHA) || 48 | (sfactor == GL_SRC_ALPHA_SATURATE && dfactor == GL_ONE) || 49 | (sfactor == GL_ONE && dfactor == GL_ZERO)) { 50 | context->blendSrcFactor = sfactor; 51 | context->blendDstFactor = dfactor; 52 | } else { 53 | VPMT_INVALID_ENUM(context); 54 | return; 55 | } 56 | } 57 | 58 | void VPMT_ExecClearColor(VPMT_Context * context, GLclampf red, GLclampf green, GLclampf blue, 59 | GLclampf alpha) 60 | { 61 | VPMT_NOT_RENDERING(context); 62 | 63 | context->clearColor[0] = VPMT_CLAMP(red); 64 | context->clearColor[1] = VPMT_CLAMP(green); 65 | context->clearColor[2] = VPMT_CLAMP(blue); 66 | context->clearColor[3] = VPMT_CLAMP(alpha); 67 | } 68 | 69 | void VPMT_ExecClearDepthf(VPMT_Context * context, GLclampf depth) 70 | { 71 | VPMT_NOT_RENDERING(context); 72 | 73 | context->clearDepth = (depth < 0.0f) ? 0.0f : (depth > 1.0f) ? 1.0f : depth; 74 | } 75 | 76 | void VPMT_ExecClearStencil(VPMT_Context * context, GLint s) 77 | { 78 | VPMT_NOT_RENDERING(context); 79 | 80 | context->clearStencil = s & 81 | (context->stencilBits < 32 ? ((1 << context->stencilBits) - 1) : ~0); 82 | } 83 | 84 | void VPMT_ExecColorMask(VPMT_Context * context, GLboolean red, GLboolean green, GLboolean blue, 85 | GLboolean alpha) 86 | { 87 | VPMT_NOT_RENDERING(context); 88 | 89 | context->colorWriteMask[0] = red; 90 | context->colorWriteMask[1] = green; 91 | context->colorWriteMask[2] = blue; 92 | context->colorWriteMask[3] = alpha; 93 | } 94 | 95 | void VPMT_ExecDepthFunc(VPMT_Context * context, GLenum func) 96 | { 97 | VPMT_NOT_RENDERING(context); 98 | 99 | switch (func) { 100 | case GL_LESS: 101 | case GL_LEQUAL: 102 | case GL_ALWAYS: 103 | context->depthFunc = func; 104 | break; 105 | 106 | default: 107 | VPMT_INVALID_ENUM(context); 108 | return; 109 | } 110 | } 111 | 112 | void VPMT_ExecDepthMask(VPMT_Context * context, GLboolean flag) 113 | { 114 | VPMT_NOT_RENDERING(context); 115 | 116 | context->depthWriteMask = flag; 117 | } 118 | 119 | void VPMT_ExecScissor(VPMT_Context * context, GLint x, GLint y, GLsizei width, GLsizei height) 120 | { 121 | VPMT_NOT_RENDERING(context); 122 | 123 | if (width < 0 || height < 0) { 124 | VPMT_INVALID_VALUE(context); 125 | return; 126 | } 127 | 128 | context->scissor.origin[0] = x; 129 | context->scissor.origin[1] = y; 130 | context->scissor.size.width = width; 131 | context->scissor.size.height = height; 132 | } 133 | 134 | void VPMT_ExecStencilFunc(VPMT_Context * context, GLenum func, GLint ref, GLuint mask) 135 | { 136 | VPMT_NOT_RENDERING(context); 137 | 138 | switch (func) { 139 | case GL_NEVER: 140 | case GL_LESS: 141 | case GL_LEQUAL: 142 | case GL_EQUAL: 143 | case GL_GEQUAL: 144 | case GL_GREATER: 145 | case GL_NOTEQUAL: 146 | case GL_ALWAYS: 147 | context->stencilFunc = func; 148 | break; 149 | 150 | default: 151 | VPMT_INVALID_ENUM(context); 152 | return; 153 | } 154 | 155 | context->stencilRef = ref; 156 | context->stencilMask = mask; 157 | } 158 | 159 | void VPMT_ExecStencilMask(VPMT_Context * context, GLuint mask) 160 | { 161 | VPMT_NOT_RENDERING(context); 162 | 163 | context->stencilWriteMask = mask; 164 | } 165 | 166 | static GLboolean IsValidStencilOp(GLenum op) 167 | { 168 | switch (op) { 169 | case GL_KEEP: 170 | case GL_ZERO: 171 | case GL_REPLACE: 172 | case GL_INCR: 173 | case GL_DECR: 174 | case GL_INVERT: 175 | return GL_TRUE; 176 | 177 | default: 178 | return GL_FALSE; 179 | } 180 | } 181 | 182 | void VPMT_ExecStencilOp(VPMT_Context * context, GLenum fail, GLenum zfail, GLenum zpass) 183 | { 184 | VPMT_NOT_RENDERING(context); 185 | 186 | if (!IsValidStencilOp(fail) || !IsValidStencilOp(zfail) || !IsValidStencilOp(zpass)) { 187 | VPMT_INVALID_ENUM(context); 188 | return; 189 | } 190 | 191 | context->stencilOpFail = fail; 192 | context->stencilOpZFail = zfail; 193 | context->stencilOpZPass = zpass; 194 | } 195 | 196 | /* 197 | ** ------------------------------------------------------------------------- 198 | ** Update the effective pixel ownership test 199 | ** ------------------------------------------------------------------------- 200 | */ 201 | 202 | void VPMT_UpdateActiveSurfaceRect(VPMT_Context * context, const VPMT_Rect * rect) 203 | { 204 | const VPMT_Surface *surface = context->writeSurface; 205 | 206 | if (!rect) { 207 | /* effectively disable all rendering */ 208 | context->activeSurfaceRect.origin[0] = 0; 209 | context->activeSurfaceRect.origin[1] = 0; 210 | context->activeSurfaceRect.size.width = 0; 211 | context->activeSurfaceRect.size.height = 0; 212 | } else { 213 | if (context->scissorTestEnabled) { 214 | VPMT_IntersectRect(&context->activeSurfaceRect, &context->scissor, rect); 215 | } else { 216 | context->activeSurfaceRect = *rect; 217 | } 218 | } 219 | } 220 | 221 | /* $Id: frag.c 74 2008-11-23 07:25:12Z hmwill $ */ 222 | -------------------------------------------------------------------------------- /lib/fragproc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Fragment processing functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "exec.h" 17 | #include "frame.h" 18 | 19 | /* 20 | ** ------------------------------------------------------------------------- 21 | ** Clear buffers 22 | ** ------------------------------------------------------------------------- 23 | */ 24 | void VPMT_ExecClear(VPMT_Context * context, GLbitfield mask) 25 | { 26 | GLuint x, y; 27 | GLsizei width, height; 28 | VPMT_FrameBuffer fb; 29 | GLuint clearDepth, clearStencil; 30 | VPMT_Color4ub clearColor; 31 | GLboolean colorComponents; 32 | 33 | VPMT_NOT_RENDERING(context); 34 | 35 | if (!context->writeSurface) { 36 | /* should this flag invalid operation? */ 37 | return; 38 | } 39 | 40 | clearDepth = (GLuint) (context->depthFixedPointScale * context->clearDepth); 41 | clearStencil = context->clearStencil; 42 | clearColor = VPMT_ConvertVec4ToColor4ub(context->clearColor); 43 | 44 | colorComponents = 45 | (context->writeSurface->image.pixelFormat->redBits && !context->colorWriteMask[0]) || 46 | (context->writeSurface->image.pixelFormat->greenBits && !context->colorWriteMask[1]) || 47 | (context->writeSurface->image.pixelFormat->blueBits && !context->colorWriteMask[2]) || 48 | (context->writeSurface->image.pixelFormat->alphaBits && !context->colorWriteMask[3]); 49 | 50 | context->writeSurface->vtbl->lock(context, context->writeSurface); 51 | VPMT_FrameBufferInit(&fb, context->writeSurface); 52 | VPMT_FrameBufferMove(&fb, context->activeSurfaceRect.origin[0], 53 | context->activeSurfaceRect.origin[1]); 54 | 55 | for (y = context->activeSurfaceRect.origin[1], height = 56 | context->activeSurfaceRect.size.height; height != 0; --height, ++y) { 57 | 58 | VPMT_FrameBufferSave(&fb); 59 | 60 | for (x = context->activeSurfaceRect.origin[0], width = 61 | context->activeSurfaceRect.size.width; width != 0; --width, ++x) { 62 | 63 | if (mask & GL_COLOR_BUFFER_BIT) { 64 | if (colorComponents) { 65 | VPMT_Color4ub color = VPMT_FrameReadColor(&fb); 66 | 67 | if (context->colorWriteMask[0]) { 68 | color.red = clearColor.red; 69 | } 70 | 71 | if (context->colorWriteMask[1]) { 72 | color.green = clearColor.green; 73 | } 74 | 75 | if (context->colorWriteMask[2]) { 76 | color.blue = clearColor.blue; 77 | } 78 | 79 | if (context->colorWriteMask[3]) { 80 | color.alpha = clearColor.alpha; 81 | } 82 | 83 | VPMT_FrameWriteColor(&fb, color); 84 | } else { 85 | VPMT_FrameWriteColor(&fb, clearColor); 86 | } 87 | } 88 | 89 | if (mask & GL_DEPTH_BUFFER_BIT) { 90 | VPMT_FrameWriteDepth(&fb, clearDepth); 91 | } 92 | 93 | if (mask & GL_STENCIL_BUFFER_BIT) { 94 | VPMT_FrameWriteStencil(&fb, clearStencil); 95 | } 96 | 97 | VPMT_FrameBufferStepX(&fb); 98 | } 99 | 100 | VPMT_FrameBufferRestore(&fb); 101 | VPMT_FrameBufferStepY(&fb); 102 | } 103 | 104 | context->writeSurface->vtbl->unlock(context, context->writeSurface); 105 | } 106 | 107 | /* 108 | ** ------------------------------------------------------------------------- 109 | ** Generate a single fragment 110 | ** ------------------------------------------------------------------------- 111 | */ 112 | 113 | static VPMT_INLINE GLubyte UByteLerp(GLubyte first, GLubyte second, GLuint lerp) 114 | { 115 | GLint diff = (GLint) second - (GLint) first; 116 | GLint scaledDiff = (diff * (GLint) lerp) >> 8; 117 | 118 | return (GLubyte) ((GLint) first + scaledDiff); 119 | } 120 | 121 | void VPMT_Fragment(VPMT_Context * context, VPMT_FrameBuffer * fb, VPMT_Color4ub newColor, 122 | GLuint depth) 123 | { 124 | GLuint oldDepth, newDepth; 125 | GLuint oldStencil, newStencil; 126 | VPMT_Color4ub oldColor; 127 | GLboolean hasMaskedColor, hasEnabledColor; 128 | GLboolean hasEnabledDepthStencil; 129 | GLboolean writeColor = GL_TRUE; 130 | 131 | /* alpha test */ 132 | if (context->alphaTestEnabled && context->alphaFunc == GL_LEQUAL) { 133 | if (newColor.alpha > context->alphaRefub) { 134 | return; 135 | } 136 | } 137 | 138 | /* depth & stencil test */ 139 | hasEnabledDepthStencil = 140 | context->depthWriteMask || context->depthTestEnabled || context->stencilTestEnabled; 141 | 142 | if (hasEnabledDepthStencil) { 143 | 144 | GLboolean depthTest; 145 | GLuint stencilBufferMask = (1 << context->stencilBits) - 1; 146 | 147 | oldDepth = VPMT_FrameReadDepth(fb); 148 | oldStencil = VPMT_FrameReadStencil(fb); 149 | 150 | if (context->depthTestEnabled) { 151 | switch (context->depthFunc) { 152 | case GL_LESS: 153 | depthTest = depth < oldDepth; 154 | break; 155 | case GL_LEQUAL: 156 | depthTest = depth <= oldDepth; 157 | break; 158 | case GL_ALWAYS: 159 | depthTest = GL_TRUE; 160 | break; 161 | default: 162 | assert(GL_FALSE); 163 | break; 164 | } 165 | } else { 166 | depthTest = GL_TRUE; 167 | } 168 | 169 | if (context->stencilTestEnabled) { 170 | 171 | GLboolean stencilTest; 172 | GLenum op; 173 | GLuint maskedRef = stencilBufferMask & context->stencilMask & context->stencilRef; 174 | GLuint maskedValue = stencilBufferMask & context->stencilMask & oldStencil; 175 | 176 | switch (context->stencilFunc) { 177 | case GL_NEVER: 178 | stencilTest = GL_FALSE; 179 | break; 180 | case GL_LESS: 181 | stencilTest = maskedRef < maskedValue; 182 | break; 183 | case GL_LEQUAL: 184 | stencilTest = maskedRef <= maskedValue; 185 | break; 186 | case GL_GREATER: 187 | stencilTest = maskedRef > maskedValue; 188 | break; 189 | case GL_GEQUAL: 190 | stencilTest = maskedRef >= maskedValue; 191 | break; 192 | case GL_EQUAL: 193 | stencilTest = maskedRef == maskedValue; 194 | break; 195 | case GL_NOTEQUAL: 196 | stencilTest = maskedRef != maskedValue; 197 | break; 198 | case GL_ALWAYS: 199 | stencilTest = GL_TRUE; 200 | break; 201 | default: 202 | assert(GL_FALSE); 203 | break; 204 | } 205 | 206 | if (!stencilTest) { 207 | op = context->stencilOpFail; 208 | writeColor = GL_FALSE; 209 | newDepth = oldDepth; 210 | } else if (!depthTest) { 211 | op = context->stencilOpZFail; 212 | writeColor = GL_FALSE; 213 | newDepth = oldDepth; 214 | } else { 215 | op = context->stencilOpZPass; 216 | newDepth = depth; 217 | } 218 | 219 | switch (op) { 220 | case GL_KEEP: 221 | newStencil = oldStencil; 222 | break; 223 | case GL_ZERO: 224 | newStencil = 0; 225 | break; 226 | case GL_REPLACE: 227 | newStencil = context->stencilRef; 228 | break; 229 | case GL_INCR: 230 | newStencil = (oldStencil < stencilBufferMask) ? oldStencil + 1 : oldStencil; 231 | break; 232 | case GL_DECR: 233 | newStencil = (oldStencil > 0) ? oldStencil - 1 : 0; 234 | break; 235 | case GL_INVERT: 236 | newStencil = ~oldStencil & stencilBufferMask; 237 | break; 238 | default: 239 | assert(GL_FALSE); 240 | break; 241 | } 242 | } else if (!depthTest) { 243 | return; 244 | } else { 245 | newStencil = oldStencil; 246 | newDepth = depth; 247 | } 248 | 249 | newDepth = VPMT_SELECT(context->depthWriteMask, newDepth, oldDepth); 250 | newStencil = 251 | ((context->stencilWriteMask & newStencil) | 252 | (~context->stencilWriteMask & oldStencil)) & stencilBufferMask; 253 | 254 | VPMT_FrameWriteDepth(fb, newDepth); 255 | VPMT_FrameWriteStencil(fb, newStencil); 256 | } 257 | 258 | /* is there any color component that needs to be written? */ 259 | hasEnabledColor = 260 | (context->redBits && context->colorWriteMask[0]) || 261 | (context->greenBits && context->colorWriteMask[1]) || 262 | (context->blueBits && context->colorWriteMask[2]) || 263 | (context->alphaBits && context->colorWriteMask[3]); 264 | 265 | if (!hasEnabledColor || !writeColor) { 266 | return; 267 | } 268 | 269 | /* is there any color component that needs to be preserved? */ 270 | hasMaskedColor = 271 | (context->redBits && !context->colorWriteMask[0]) || 272 | (context->greenBits && !context->colorWriteMask[1]) || 273 | (context->blueBits && !context->colorWriteMask[2]) || 274 | (context->alphaBits && !context->colorWriteMask[3]); 275 | 276 | /* perform blend */ 277 | if ((context->blendEnabled && context->blendSrcFactor != GL_ONE) || hasMaskedColor) { 278 | 279 | oldColor = VPMT_FrameReadColor(fb); 280 | 281 | if (context->blendEnabled) { 282 | /* OpenGL SC only provides the following two blend modes */ 283 | if (context->blendSrcFactor == GL_SRC_ALPHA 284 | && context->blendDstFactor == GL_ONE_MINUS_SRC_ALPHA) { 285 | GLuint alpha256 = VPMT_Color255To256(newColor.alpha); 286 | 287 | newColor.red = UByteLerp(oldColor.red, newColor.red, alpha256); 288 | newColor.green = UByteLerp(oldColor.green, newColor.green, alpha256); 289 | newColor.blue = UByteLerp(oldColor.blue, newColor.blue, alpha256); 290 | newColor.alpha = UByteLerp(oldColor.alpha, newColor.alpha, alpha256); 291 | 292 | } else if (context->blendSrcFactor == GL_SRC_ALPHA_SATURATE 293 | && context->blendDstFactor == GL_ONE) { 294 | GLubyte alpha = VPMT_MIN(newColor.alpha, 0xffu - oldColor.alpha); 295 | GLuint alpha256 = VPMT_Color255To256(alpha); 296 | 297 | newColor.red = (GLubyte) VPMT_MIN(VPMT_UBYTE_MAX, (GLushort) oldColor.red + VPMT_UByteMul256(newColor.red, alpha256)); 298 | newColor.green = (GLubyte) VPMT_MIN(VPMT_UBYTE_MAX, (GLushort) oldColor.green + VPMT_UByteMul256(newColor.green, alpha256)); 299 | newColor.blue = (GLubyte) VPMT_MIN(VPMT_UBYTE_MAX, (GLushort) oldColor.blue + VPMT_UByteMul256(newColor.blue, alpha256)); 300 | newColor.alpha = oldColor.alpha + alpha; /* this is clamped at 0..1 */ 301 | } else { 302 | assert(context->blendSrcFactor == GL_ONE && context->blendDstFactor == GL_ZERO); 303 | } 304 | } 305 | 306 | /* multiplex color components based on colorWriteMask */ 307 | newColor.red = VPMT_SELECT(context->colorWriteMask[0], newColor.red, oldColor.red); 308 | newColor.green = VPMT_SELECT(context->colorWriteMask[1], newColor.green, oldColor.green); 309 | newColor.blue = VPMT_SELECT(context->colorWriteMask[2], newColor.blue, oldColor.blue); 310 | newColor.alpha = VPMT_SELECT(context->colorWriteMask[3], newColor.alpha, oldColor.alpha); 311 | } 312 | 313 | /* write to framebuffer */ 314 | VPMT_FrameWriteColor(fb, newColor); 315 | } 316 | 317 | /* $Id: fragproc.c 74 2008-11-23 07:25:12Z hmwill $ */ 318 | -------------------------------------------------------------------------------- /lib/frame.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Framebuffer Access 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "frame.h" 17 | 18 | 19 | static VPMT_Color4ub ReadColor565(const VPMT_FrameBuffer * fb) 20 | { 21 | const GLushort *ptr = (const GLushort *) fb->current[0]; 22 | VPMT_Color4ub result; 23 | 24 | result.red = (*ptr & 0xF800) >> 8 | (*ptr & 0xF800) >> 13; 25 | result.green = (*ptr & 0x07E0) >> 3 | (*ptr & 0x07E0) >> 9; 26 | result.blue = (*ptr & 0x001F) << 3 | (*ptr & 0x001F) >> 2; 27 | result.alpha = 0xffu; 28 | 29 | return result; 30 | } 31 | 32 | static void WriteColor565(const VPMT_FrameBuffer * fb, VPMT_Color4ub color) 33 | { 34 | GLushort *ptr = (GLushort *) fb->current[0]; 35 | 36 | *ptr = 37 | ((color.red << 8) & 0xF800) | ((color.green << 3) & 0x07E0) | ((color.blue >> 3) & 0x001F); 38 | } 39 | 40 | static VPMT_Color4ub ReadColor5551(const VPMT_FrameBuffer * fb) 41 | { 42 | const GLushort *ptr = (const GLushort *) fb->current[0]; 43 | VPMT_Color4ub result; 44 | 45 | result.red = (*ptr & 0xF800) >> 8 | (*ptr & 0xF800) >> 13; 46 | result.green = (*ptr & 0x07C0) >> 3 | (*ptr & 0x07C0) >> 8; 47 | result.blue = (*ptr & 0x003E) << 2 | (*ptr & 0x003E) >> 3; 48 | result.alpha = (*ptr & 1) ? 0xffu : 0u; 49 | 50 | return result; 51 | } 52 | 53 | static void WriteColor5551(const VPMT_FrameBuffer * fb, VPMT_Color4ub color) 54 | { 55 | GLushort *ptr = (GLushort *) fb->current[0]; 56 | 57 | *ptr = 58 | ((color.red << 8) & 0xF800) | 59 | ((color.green << 3) & 0x07C0) | ((color.blue >> 2) & 0x003E) | ((color.alpha >> 7) & 1); 60 | } 61 | 62 | static VPMT_Color4ub ReadColor4444(const VPMT_FrameBuffer * fb) 63 | { 64 | const GLushort *ptr = (const GLushort *) fb->current[0]; 65 | VPMT_Color4ub result; 66 | 67 | result.red = (*ptr & 0xF000) >> 8 | (*ptr & 0xF000) >> 12; 68 | result.green = (*ptr & 0x0F00) >> 4 | (*ptr & 0x0F00) >> 8; 69 | result.blue = (*ptr & 0x00F0) | (*ptr & 0x00F0) >> 4; 70 | result.alpha = (*ptr & 0x000F) << 4 | (*ptr & 0x000F); 71 | 72 | return result; 73 | } 74 | 75 | static void WriteColor4444(const VPMT_FrameBuffer * fb, VPMT_Color4ub color) 76 | { 77 | GLushort *ptr = (GLushort *) fb->current[0]; 78 | 79 | *ptr = 80 | ((color.red << 8) & 0xF000) | 81 | ((color.green << 4) & 0x0F00) | ((color.blue) & 0x00F0) | ((color.alpha >> 4) & 0x000F); 82 | } 83 | 84 | static VPMT_Color4ub ReadColor8888(const VPMT_FrameBuffer * fb) 85 | { 86 | const GLuint *ptr = (const GLuint *) fb->current[0]; 87 | VPMT_Color4ub result; 88 | 89 | result.red = (*ptr & 0xFF000000) >> 24; 90 | result.green = (*ptr & 0x00FF0000) >> 16; 91 | result.blue = (*ptr & 0x0000FF00) >> 8; 92 | result.alpha = (*ptr & 0x000000FF); 93 | 94 | return result; 95 | } 96 | 97 | static void WriteColor8888(const VPMT_FrameBuffer * fb, VPMT_Color4ub color) 98 | { 99 | GLuint *ptr = (GLuint *) fb->current[0]; 100 | 101 | *ptr = color.red << 24 | color.green << 16 | color.blue << 8 | color.alpha; 102 | } 103 | 104 | static VPMT_Color4ub ReadColor8888_REV(const VPMT_FrameBuffer * fb) 105 | { 106 | const GLuint *ptr = (const GLuint *) fb->current[0]; 107 | VPMT_Color4ub result; 108 | 109 | result.red = (*ptr & 0x000000FF); 110 | result.green = (*ptr & 0x0000FF00) >> 8; 111 | result.blue = (*ptr & 0x00FF0000) >> 16; 112 | result.alpha = (*ptr & 0xFF000000) >> 24; 113 | 114 | return result; 115 | } 116 | 117 | static void WriteColor8888_REV(const VPMT_FrameBuffer * fb, VPMT_Color4ub color) 118 | { 119 | GLuint *ptr = (GLuint *) fb->current[0]; 120 | 121 | *ptr = color.alpha << 24 | color.blue << 16 | color.green << 8 | color.red; 122 | } 123 | 124 | static GLuint ReadDepth16(const VPMT_FrameBuffer * fb) 125 | { 126 | const GLushort *ptr = (const GLushort *) fb->current[1]; 127 | return *ptr; 128 | } 129 | 130 | static void WriteDepth16(const VPMT_FrameBuffer * fb, GLuint depth) 131 | { 132 | GLushort *ptr = (GLushort *) fb->current[1]; 133 | assert(!(depth & ~0xffffffu)); 134 | *ptr = depth; 135 | } 136 | 137 | static GLuint ReadDepthD24S8(const VPMT_FrameBuffer * fb) 138 | { 139 | const GLuint *ptr = (const GLuint *) fb->current[1]; 140 | return *ptr >> 8; 141 | } 142 | 143 | static void WriteDepthD24S8(const VPMT_FrameBuffer * fb, GLuint depth) 144 | { 145 | GLuint *ptr = (GLuint *) fb->current[1]; 146 | assert(!(depth & ~0xffffffu)); 147 | *ptr = (*ptr & 0xff) | (depth << 8); 148 | } 149 | 150 | static GLuint ReadDepth32(const VPMT_FrameBuffer * fb) 151 | { 152 | const GLuint *ptr = (const GLuint *) fb->current[1]; 153 | return *ptr; 154 | } 155 | 156 | static void WriteDepth32(const VPMT_FrameBuffer * fb, GLuint depth) 157 | { 158 | GLuint *ptr = (GLuint *) fb->current[1]; 159 | *ptr = depth; 160 | } 161 | 162 | static GLuint ReadStencil0(const VPMT_FrameBuffer * fb) 163 | { 164 | return 0u; 165 | } 166 | 167 | static void WriteStencil0(const VPMT_FrameBuffer * fb, GLuint stencil) 168 | { 169 | assert(!stencil); 170 | } 171 | 172 | static GLuint ReadStencilD24S8(const VPMT_FrameBuffer * fb) 173 | { 174 | const GLuint *ptr = (const GLuint *) fb->current[1]; 175 | return *ptr & 0xffu; 176 | } 177 | 178 | static void WriteStencilD24S8(const VPMT_FrameBuffer * fb, GLuint stencil) 179 | { 180 | GLuint *ptr = (GLuint *) fb->current[1]; 181 | assert(!(stencil & ~0xffu)); 182 | *ptr = (stencil & 0xffu) | (*ptr & 0xffffff00u); 183 | } 184 | 185 | /* 186 | ** ------------------------------------------------------------------------- 187 | ** Exported Functions 188 | ** ------------------------------------------------------------------------- 189 | */ 190 | 191 | void VPMT_FrameBufferInit(VPMT_FrameBuffer * fb, VPMT_Surface * surface) 192 | { 193 | const VPMT_PixelFormat *pixelFormat = surface->image.pixelFormat; 194 | 195 | /* this code assumes 2 buffers; RGBA and depth/stencil */ 196 | fb->current[0] = ((GLubyte *) surface->image.data); 197 | fb->dx[0] = surface->image.pixelFormat->size; 198 | fb->dy[0] = surface->image.pitch; 199 | 200 | fb->current[1] = ((GLubyte *) surface->depthStencilBuffer); 201 | fb->dx[1] = surface->depthStencilFormat->bits / 8; 202 | fb->dy[1] = surface->depthStencilFormat->bits / 8 * surface->image.size.width; 203 | 204 | switch (pixelFormat->baseFormat) { 205 | case GL_RGB: 206 | switch (pixelFormat->type) { 207 | case GL_UNSIGNED_SHORT_5_6_5: 208 | fb->readColor = ReadColor565; 209 | fb->writeColor = WriteColor565; 210 | break; 211 | 212 | default: 213 | assert(GL_FALSE); 214 | fb->readColor = NULL; 215 | fb->writeColor = NULL; 216 | } 217 | 218 | break; 219 | 220 | case GL_RGBA: 221 | switch (pixelFormat->type) { 222 | case GL_UNSIGNED_SHORT_4_4_4_4: 223 | fb->readColor = ReadColor4444; 224 | fb->writeColor = WriteColor4444; 225 | break; 226 | 227 | case GL_UNSIGNED_SHORT_5_5_5_1: 228 | fb->readColor = ReadColor5551; 229 | fb->writeColor = WriteColor5551; 230 | break; 231 | 232 | #if (!VPMT_LITTLE_ENDIAN) 233 | case GL_UNSIGNED_BYTE: 234 | #endif 235 | case GL_UNSIGNED_INT_8_8_8_8: 236 | fb->readColor = ReadColor8888; 237 | fb->writeColor = WriteColor8888; 238 | break; 239 | 240 | #if (VPMT_LITTLE_ENDIAN) 241 | case GL_UNSIGNED_BYTE: 242 | #endif 243 | case GL_UNSIGNED_INT_8_8_8_8_REV: 244 | fb->readColor = ReadColor8888_REV; 245 | fb->writeColor = WriteColor8888_REV; 246 | break; 247 | 248 | default: 249 | assert(GL_FALSE); 250 | fb->readColor = NULL; 251 | fb->writeColor = NULL; 252 | } 253 | 254 | break; 255 | } 256 | 257 | switch (surface->depthStencilFormat->type) { 258 | case VPMT_DEPTH_16: 259 | fb->readDepth = ReadDepth16; 260 | fb->writeDepth = WriteDepth16; 261 | fb->readStencil = ReadStencil0; 262 | fb->writeStencil = WriteStencil0; 263 | break; 264 | 265 | case VPMT_DEPTH_24_STENCIL_8: 266 | fb->readDepth = ReadDepthD24S8; 267 | fb->writeDepth = WriteDepthD24S8; 268 | fb->readStencil = ReadStencilD24S8; 269 | fb->writeStencil = WriteStencilD24S8; 270 | break; 271 | 272 | case VPMT_DEPTH_32: 273 | fb->readDepth = ReadDepth32; 274 | fb->writeDepth = WriteDepth32; 275 | fb->readStencil = ReadStencil0; 276 | fb->writeStencil = WriteStencil0; 277 | break; 278 | 279 | default: 280 | fb->readDepth = NULL; 281 | fb->writeDepth = NULL; 282 | fb->readStencil = NULL; 283 | fb->writeStencil = NULL; 284 | } 285 | } 286 | 287 | /* $Id: frame.c 74 2008-11-23 07:25:12Z hmwill $ */ 288 | -------------------------------------------------------------------------------- /lib/frame.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Framebuffer Access 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_FRAME_H 14 | #define VPMT_FRAME_H 15 | 16 | #include "context.h" 17 | 18 | typedef struct VPMT_FrameBuffer VPMT_FrameBuffer; 19 | 20 | typedef VPMT_Color4ub(*VPMT_FrameReadColorFunc) (const VPMT_FrameBuffer * fb); 21 | typedef void (*VPMT_FrameWriteColorFunc) (const VPMT_FrameBuffer * fb, VPMT_Color4ub color); 22 | typedef GLuint(*VPMT_FrameReadDepthFunc) (const VPMT_FrameBuffer * fb); 23 | typedef void (*VPMT_FrameWriteDepthFunc) (const VPMT_FrameBuffer * fb, GLuint depth); 24 | typedef GLuint(*VPMT_FrameReadStencilFunc) (const VPMT_FrameBuffer * fb); 25 | typedef void (*VPMT_FrameWriteStencilFunc) (const VPMT_FrameBuffer * fb, GLuint stencil); 26 | 27 | struct VPMT_FrameBuffer { 28 | GLubyte *current[VPMT_MAX_RENDER_BUFFERS]; /* current addresses of buffer pointers */ 29 | GLsizei dx[VPMT_MAX_RENDER_BUFFERS]; /* increment in positive X */ 30 | GLsizei dy[VPMT_MAX_RENDER_BUFFERS]; /* increment in positive Y */ 31 | GLubyte *save[VPMT_MAX_RENDER_BUFFERS]; /* address save area */ 32 | 33 | VPMT_FrameReadColorFunc readColor; 34 | VPMT_FrameWriteColorFunc writeColor; 35 | VPMT_FrameReadDepthFunc readDepth; 36 | VPMT_FrameWriteDepthFunc writeDepth; 37 | VPMT_FrameReadStencilFunc readStencil; 38 | VPMT_FrameWriteStencilFunc writeStencil; 39 | }; 40 | 41 | //void VPMT_FrameBufferClear(VPMT_FrameBuffer * fb, VPMT_Color4ub clearColor, GLuint clearDepth, GLuint clearStencil); 42 | void VPMT_FrameBufferInit(VPMT_FrameBuffer * fb, VPMT_Surface * surface); 43 | 44 | static VPMT_INLINE void VPMT_FrameBufferMove(VPMT_FrameBuffer * fb, GLint deltaX, GLint deltaY) 45 | { 46 | GLsizei index; 47 | 48 | for (index = 0; index < VPMT_MAX_RENDER_BUFFERS; ++index) { 49 | fb->current[index] += fb->dx[index] * deltaX + fb->dy[index] * deltaY; 50 | } 51 | } 52 | 53 | static VPMT_INLINE void VPMT_FrameBufferStepX(VPMT_FrameBuffer * fb) 54 | { 55 | GLsizei index; 56 | 57 | for (index = 0; index < VPMT_MAX_RENDER_BUFFERS; ++index) { 58 | fb->current[index] += fb->dx[index]; 59 | } 60 | } 61 | 62 | static VPMT_INLINE void VPMT_FrameBufferStepNegX(VPMT_FrameBuffer * fb) 63 | { 64 | GLsizei index; 65 | 66 | for (index = 0; index < VPMT_MAX_RENDER_BUFFERS; ++index) { 67 | fb->current[index] -= fb->dx[index]; 68 | } 69 | } 70 | 71 | static VPMT_INLINE void VPMT_FrameBufferStepY(VPMT_FrameBuffer * fb) 72 | { 73 | GLsizei index; 74 | 75 | for (index = 0; index < VPMT_MAX_RENDER_BUFFERS; ++index) { 76 | fb->current[index] += fb->dy[index]; 77 | } 78 | } 79 | 80 | static VPMT_INLINE void VPMT_FrameBufferSave(VPMT_FrameBuffer * fb) 81 | { 82 | GLsizei index; 83 | 84 | for (index = 0; index < VPMT_MAX_RENDER_BUFFERS; ++index) { 85 | fb->save[index] = fb->current[index]; 86 | } 87 | } 88 | 89 | static VPMT_INLINE void VPMT_FrameBufferRestore(VPMT_FrameBuffer * fb) 90 | { 91 | GLsizei index; 92 | 93 | for (index = 0; index < VPMT_MAX_RENDER_BUFFERS; ++index) { 94 | fb->current[index] = fb->save[index]; 95 | } 96 | } 97 | 98 | 99 | static VPMT_INLINE VPMT_Color4ub VPMT_FrameReadColor(const VPMT_FrameBuffer * fb) 100 | { 101 | return fb->readColor(fb); 102 | } 103 | 104 | static VPMT_INLINE void VPMT_FrameWriteColor(const VPMT_FrameBuffer * fb, VPMT_Color4ub color) 105 | { 106 | fb->writeColor(fb, color); 107 | } 108 | 109 | static VPMT_INLINE GLuint VPMT_FrameReadDepth(const VPMT_FrameBuffer * fb) 110 | { 111 | return fb->readDepth(fb); 112 | } 113 | 114 | static VPMT_INLINE void VPMT_FrameWriteDepth(const VPMT_FrameBuffer * fb, GLuint depth) 115 | { 116 | fb->writeDepth(fb, depth); 117 | } 118 | 119 | static VPMT_INLINE GLuint VPMT_FrameReadStencil(const VPMT_FrameBuffer * fb) 120 | { 121 | return fb->readStencil(fb); 122 | } 123 | 124 | static VPMT_INLINE void VPMT_FrameWriteStencil(const VPMT_FrameBuffer * fb, GLuint stencil) 125 | { 126 | fb->writeStencil(fb, stencil); 127 | } 128 | 129 | #endif 130 | 131 | /* $Id: frame.h 74 2008-11-23 07:25:12Z hmwill $ */ 132 | -------------------------------------------------------------------------------- /lib/glint.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Internal GL constants 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_GLINT_H 14 | #define VPMT_GLINT_H 15 | 16 | /* BeginMode */ 17 | #define GL_INVALID_MODE 0xFF 18 | 19 | /* Re-introduce BGRA texture format */ 20 | #define GL_BGRA 0x80E1 21 | 22 | /* Re-introduce 32-bit word encoding of 32-bit RGBA values */ 23 | #define GL_UNSIGNED_INT_8_8_8_8 0x8035 24 | #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 25 | #define GL_UNSIGNED_SHORT_5_6_5 0x8363 26 | #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 27 | #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 28 | 29 | /* Functions */ 30 | 31 | GLAPI void APIENTRY glDeleteLists (GLuint list, GLsizei range); 32 | GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); 33 | 34 | #endif 35 | 36 | /* $Id$ */ 37 | -------------------------------------------------------------------------------- /lib/hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Hash table implementation for list management. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | 17 | void VPMT_HashTableInitialize(VPMT_HashTable * table) 18 | { 19 | memset(table, 0, sizeof *table); 20 | } 21 | 22 | void VPMT_HashTableDeinitialize(VPMT_HashTable * table) 23 | { 24 | GLsizei index; 25 | 26 | for (index = 0; index < VPMT_HASH_SIZE; ++index) { 27 | VPMT_HashEntry *entry, *next; 28 | 29 | for (entry = table->buckets[index]; entry; entry = next) { 30 | next = entry->next; 31 | VPMT_FREE(entry); 32 | } 33 | } 34 | } 35 | 36 | void VPMT_HashTableIterate(VPMT_HashTable * table, VPMT_HashTableIterFunc func, void * arg) 37 | { 38 | GLsizei index; 39 | 40 | for (index = 0; index < VPMT_HASH_SIZE; ++index) { 41 | VPMT_HashEntry *entry; 42 | 43 | for (entry = table->buckets[index]; entry; entry = entry->next) { 44 | func(entry->key, entry->value, arg); 45 | } 46 | } 47 | } 48 | 49 | void *VPMT_HashTableFind(VPMT_HashTable * table, GLuint key) 50 | { 51 | 52 | if (key <= table->maxKey) { 53 | GLsizei index = key % VPMT_HASH_SIZE; 54 | VPMT_HashEntry *entry = table->buckets[index]; 55 | 56 | while (entry) { 57 | if (entry->key == key) { 58 | return entry->value; 59 | } 60 | 61 | entry = entry->next; 62 | } 63 | } 64 | 65 | return NULL; 66 | } 67 | 68 | void VPMT_HashTableRemove(VPMT_HashTable * table, GLuint key) 69 | { 70 | GLsizei index = key % VPMT_HASH_SIZE; 71 | VPMT_HashEntry **pentry = &table->buckets[index]; 72 | 73 | while (*pentry) { 74 | if ((*pentry)->key == key) { 75 | VPMT_HashEntry *entry = *pentry; 76 | *pentry = (*pentry)->next; 77 | VPMT_FREE(entry); 78 | return; 79 | } 80 | 81 | pentry = &(*pentry)->next; 82 | } 83 | } 84 | 85 | GLboolean VPMT_HashTableInsert(VPMT_HashTable * table, GLuint key, void *value) 86 | { 87 | GLsizei index = key % VPMT_HASH_SIZE; 88 | VPMT_HashEntry *entry; 89 | 90 | if (key <= table->maxKey) { 91 | entry = table->buckets[index]; 92 | 93 | while (entry) { 94 | if (entry->key == key) { 95 | entry->value = value; 96 | 97 | if (table->maxKey < key) { 98 | table->maxKey = key; 99 | } 100 | 101 | return GL_TRUE; 102 | } 103 | 104 | entry = entry->next; 105 | } 106 | } 107 | 108 | entry = VPMT_MALLOC(sizeof(VPMT_HashEntry)); 109 | 110 | if (!entry) { 111 | return GL_FALSE; 112 | } 113 | 114 | entry->next = table->buckets[index]; 115 | entry->key = key; 116 | entry->value = value; 117 | table->buckets[index] = entry; 118 | 119 | if (table->maxKey < key) { 120 | table->maxKey = key; 121 | } 122 | 123 | return GL_TRUE; 124 | } 125 | 126 | GLuint VPMT_HashTableFreeKeyBlock(VPMT_HashTable * table, GLsizei numKeys) 127 | { 128 | const GLuint maxKey = ~0u; 129 | 130 | /* 131 | ** This is an extremely simplistic implementation because OpenGL SC does not 132 | ** forsee release of resources. 133 | */ 134 | 135 | if (maxKey - numKeys > table->maxKey) { 136 | return table->maxKey + 1; 137 | } else { 138 | /* no block found */ 139 | return 0; 140 | } 141 | } 142 | 143 | /* $Id: hash.c 74 2008-11-23 07:25:12Z hmwill $ */ 144 | -------------------------------------------------------------------------------- /lib/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Hash table implementation for list management. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_HASH_H 14 | #define VPMT_HASH_H 15 | 16 | typedef struct VPMT_HashEntry { 17 | struct VPMT_HashEntry *next; 18 | GLuint key; 19 | void *value; 20 | } VPMT_HashEntry; 21 | 22 | typedef struct VPMT_HashTable { 23 | VPMT_HashEntry *buckets[VPMT_HASH_SIZE]; 24 | GLuint maxKey; 25 | } VPMT_HashTable; 26 | 27 | typedef void (*VPMT_HashTableIterFunc)(GLuint key, void * value, void * arg); 28 | 29 | void VPMT_HashTableInitialize(VPMT_HashTable * table); 30 | void VPMT_HashTableDeinitialize(VPMT_HashTable * table); 31 | void *VPMT_HashTableFind(VPMT_HashTable * table, GLuint key); 32 | void VPMT_HashTableIterate(VPMT_HashTable * table, VPMT_HashTableIterFunc func, void * arg); 33 | void VPMT_HashTableRemove(VPMT_HashTable * table, GLuint key); 34 | GLboolean VPMT_HashTableInsert(VPMT_HashTable * table, GLuint key, void *value); 35 | GLuint VPMT_HashTableFreeKeyBlock(VPMT_HashTable * table, GLsizei numKeys); 36 | 37 | #endif 38 | 39 | /* $Id: hash.h 74 2008-11-23 07:25:12Z hmwill $ */ 40 | -------------------------------------------------------------------------------- /lib/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Image and Pixel Surface Representation 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_IMAGE_H 14 | #define VPMT_IMAGE_H 15 | 16 | #include "glint.h" 17 | #include "util.h" 18 | 19 | typedef struct VPMT_Image2D VPMT_Image2D; 20 | typedef VPMT_Image2D VPMT_Image1D; 21 | 22 | typedef VPMT_Color4ub(*VPMT_Image2DReadFunc) (const VPMT_Image2D * image, 23 | #if GL_EXT_paletted_texture 24 | const VPMT_Image1D * palette, 25 | #endif 26 | GLuint x, GLuint y); 27 | typedef void (*VPMT_Image2DWriteFunc) (const VPMT_Image2D * image, 28 | GLuint x, GLuint y, VPMT_Color4ub rgba); 29 | 30 | typedef struct VPMT_PixelFormat { 31 | GLenum internalFormat; 32 | GLenum baseFormat; 33 | GLenum type; 34 | GLsizei size; 35 | GLsizei bits; 36 | GLsizei redBits; 37 | GLsizei greenBits; 38 | GLsizei blueBits; 39 | GLsizei alphaBits; 40 | GLuint redMask; 41 | GLuint blueMask; 42 | GLuint greenMask; 43 | GLuint alphaMask; 44 | VPMT_Image2DReadFunc read; 45 | VPMT_Image2DWriteFunc write; 46 | } VPMT_PixelFormat; 47 | 48 | const VPMT_PixelFormat *VPMT_GetPixelFormat(GLenum format, GLenum type); 49 | 50 | typedef enum { 51 | VPMT_DEPTH_16, 52 | VPMT_DEPTH_24_STENCIL_8, 53 | VPMT_DEPTH_32 54 | } VPMT_DepthStencilType; 55 | 56 | typedef struct VPMT_DepthStencilFormat { 57 | VPMT_DepthStencilType type; 58 | GLsizei bits; 59 | GLsizei depthBits; 60 | GLsizei stencilBits; 61 | } VPMT_DepthStencilFormat; 62 | 63 | const VPMT_DepthStencilFormat *VPMT_GetDepthStencilFormat(VPMT_DepthStencilType type); 64 | 65 | struct VPMT_Image2D { 66 | void *data; 67 | VPMT_Size size; 68 | VPMT_Sizef invSize2; 69 | GLsizei pitch; 70 | const VPMT_PixelFormat *pixelFormat; 71 | }; 72 | 73 | VPMT_Image2D *VPMT_Image2DAllocate(const VPMT_PixelFormat * pixelFormat, GLushort width, 74 | GLushort height); 75 | void VPMT_Image2DDeallocate(VPMT_Image2D * image); 76 | void VPMT_Image2DInit(VPMT_Image2D * image, const VPMT_PixelFormat * pixelFormat, GLsizei pitch, 77 | GLushort width, GLushort height, void *data); 78 | 79 | static VPMT_INLINE VPMT_Image1D *VPMT_Image1DAllocate(const VPMT_PixelFormat * pixelFormat, 80 | GLushort width) 81 | { 82 | return (VPMT_Image1D *) VPMT_Image2DAllocate(pixelFormat, width, 1); 83 | } 84 | 85 | static VPMT_INLINE void VPMT_Image1DDeallocate(VPMT_Image1D * image) 86 | { 87 | VPMT_Image2DDeallocate((VPMT_Image2D *) image); 88 | } 89 | 90 | static VPMT_INLINE void 91 | VPMT_Image1DInit(VPMT_Image1D * image, const VPMT_PixelFormat * pixelFormat, 92 | GLushort width, void *data) 93 | { 94 | VPMT_Image2DInit((VPMT_Image2D *) image, pixelFormat, 0, width, 1, data); 95 | } 96 | 97 | static VPMT_INLINE VPMT_Color4ub VPMT_Image2DRead(const VPMT_Image2D * image, 98 | #if GL_EXT_paletted_texture 99 | const VPMT_Image1D * palette, 100 | #endif 101 | GLuint x, GLuint y) 102 | { 103 | #if GL_EXT_paletted_texture 104 | return image->pixelFormat->read(image, palette, x, y); 105 | #else 106 | return image->pixelFormat->read(image, x, y); 107 | #endif 108 | } 109 | 110 | static VPMT_INLINE void VPMT_Image2DWrite(const VPMT_Image2D * image, GLuint x, GLuint y, 111 | VPMT_Color4ub rgba) 112 | { 113 | image->pixelFormat->write(image, x, y, rgba); 114 | } 115 | 116 | typedef VPMT_Color4us(*VPMT_Image2DSampleFunc) (const VPMT_Image2D * image, 117 | #if GL_EXT_paletted_texture 118 | const VPMT_Image1D * palette, 119 | #endif 120 | GLfloat s, GLenum wrapS, GLfloat t, GLenum wrapT); 121 | 122 | #endif 123 | 124 | /* $Id: image.h 74 2008-11-23 07:25:12Z hmwill $ */ 125 | -------------------------------------------------------------------------------- /lib/library.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** C Runtime Library Includes 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_LIBRARY_H 14 | #define VPMT_LIBRARY_H 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #endif 25 | 26 | /* $Id: library.h 74 2008-11-23 07:25:12Z hmwill $ */ 27 | -------------------------------------------------------------------------------- /lib/light.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Light and material functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | 17 | /* 18 | ** ------------------------------------------------------------------------- 19 | ** Exported API entry points 20 | ** ------------------------------------------------------------------------- 21 | */ 22 | 23 | void VPMT_ExecGetLightfv(VPMT_Context * context, GLenum light, GLenum pname, GLfloat * params) 24 | { 25 | GLint index; 26 | 27 | VPMT_NOT_RENDERING(context); 28 | 29 | if (light < GL_LIGHT0 || light > GL_LIGHT1) { 30 | VPMT_INVALID_ENUM(context); 31 | return; 32 | } 33 | 34 | if (!params) { 35 | VPMT_INVALID_VALUE(context); 36 | return; 37 | } 38 | 39 | index = light - GL_LIGHT0; 40 | 41 | switch (pname) { 42 | case GL_AMBIENT: 43 | VPMT_Vec4Copy(params, context->lightAmbient[index]); 44 | break; 45 | 46 | case GL_DIFFUSE: 47 | VPMT_Vec4Copy(params, context->lightDiffuse[index]); 48 | break; 49 | 50 | case GL_SPECULAR: 51 | VPMT_Vec4Copy(params, context->lightSpecular[index]); 52 | break; 53 | 54 | case GL_POSITION: 55 | VPMT_Vec4Copy(params, context->lightPosition[index]); 56 | break; 57 | 58 | default: 59 | VPMT_INVALID_VALUE(context); 60 | return; 61 | } 62 | } 63 | 64 | void VPMT_ExecGetMaterialfv(VPMT_Context * context, GLenum face, GLenum pname, GLfloat * params) 65 | { 66 | VPMT_NOT_RENDERING(context); 67 | 68 | if (face != GL_FRONT_AND_BACK) { 69 | VPMT_INVALID_ENUM(context); 70 | return; 71 | } 72 | 73 | if (!params) { 74 | VPMT_INVALID_VALUE(context); 75 | return; 76 | } 77 | 78 | switch (pname) { 79 | case GL_AMBIENT: 80 | VPMT_Vec4Copy(params, context->materialAmbient); 81 | break; 82 | 83 | case GL_DIFFUSE: 84 | VPMT_Vec4Copy(params, context->materialDiffuse); 85 | break; 86 | 87 | case GL_SPECULAR: 88 | VPMT_Vec4Copy(params, context->materialSpecular); 89 | break; 90 | 91 | case GL_EMISSION: 92 | VPMT_Vec4Copy(params, context->materialEmission); 93 | break; 94 | 95 | case GL_SHININESS: 96 | *params = context->materialShininess; 97 | break; 98 | 99 | default: 100 | VPMT_INVALID_VALUE(context); 101 | break; 102 | } 103 | } 104 | 105 | void VPMT_ExecLightfv(VPMT_Context * context, GLenum light, GLenum pname, const GLfloat * params) 106 | { 107 | GLint index; 108 | GLfloat factor; 109 | VPMT_Vec4 transformed; 110 | 111 | VPMT_NOT_RENDERING(context); 112 | 113 | if (light < GL_LIGHT0 || light > GL_LIGHT1) { 114 | VPMT_INVALID_ENUM(context); 115 | return; 116 | } 117 | 118 | if (!params) { 119 | VPMT_INVALID_VALUE(context); 120 | return; 121 | } 122 | 123 | index = light - GL_LIGHT0; 124 | 125 | switch (pname) { 126 | case GL_AMBIENT: 127 | VPMT_Vec4Copy(context->lightAmbient[index], params); 128 | break; 129 | 130 | case GL_DIFFUSE: 131 | VPMT_Vec4Copy(context->lightDiffuse[index], params); 132 | break; 133 | 134 | case GL_SPECULAR: 135 | VPMT_Vec4Copy(context->lightSpecular[index], params); 136 | break; 137 | 138 | case GL_POSITION: 139 | if (params[3] != 0.0f) { 140 | /* only directional light is supported */ 141 | VPMT_INVALID_VALUE(context); 142 | return; 143 | } 144 | 145 | VPMT_MatrixTransform4x3(context->modelviewMatrixStack. 146 | base[context->modelviewMatrixStack.current - 1], 147 | transformed, params); 148 | 149 | VPMT_Vec4Copy(context->lightPosition[index], transformed); 150 | 151 | /* we only have directional light, so let's precalculate the normalized light direction */ 152 | factor = 1.0f / sqrtf(VPMT_Vec3Dot(transformed, transformed)); 153 | 154 | VPMT_Vec3Scale(transformed, transformed, factor); 155 | transformed[3] = 0.0f; 156 | VPMT_Vec3Copy(context->lightDirection[index], transformed); 157 | 158 | /* precalculate the normalized highlight direction */ 159 | transformed[2] += 1.0f; 160 | factor = 1.0f / sqrtf(VPMT_Vec3Dot(transformed, transformed)); 161 | VPMT_Vec3Scale(context->lightHighlightDirection[index], transformed, factor); 162 | context->lightHighlightDirection[index][3] = 0.0f; 163 | 164 | break; 165 | 166 | default: 167 | VPMT_INVALID_VALUE(context); 168 | return; 169 | } 170 | } 171 | 172 | void VPMT_ExecLightModelf(VPMT_Context * context, GLenum pname, GLfloat param) 173 | { 174 | VPMT_INVALID_ENUM(context); 175 | 176 | /* is this actually a mistake in the specification? */ 177 | } 178 | 179 | void VPMT_ExecLightModelfv(VPMT_Context * context, GLenum pname, const GLfloat * params) 180 | { 181 | VPMT_NOT_RENDERING(context); 182 | 183 | if (!params) { 184 | VPMT_INVALID_VALUE(context); 185 | return; 186 | } 187 | 188 | switch (pname) { 189 | case GL_LIGHT_MODEL_AMBIENT: 190 | VPMT_Vec4Copy(context->lightModelAmbient, params); 191 | break; 192 | 193 | default: 194 | VPMT_INVALID_ENUM(context); 195 | return; 196 | } 197 | } 198 | 199 | void VPMT_ExecMaterialf(VPMT_Context * context, GLenum face, GLenum pname, GLfloat param) 200 | { 201 | if (face != GL_FRONT_AND_BACK) { 202 | VPMT_INVALID_ENUM(context); 203 | return; 204 | } 205 | 206 | switch (pname) { 207 | case GL_SHININESS: 208 | if (param < 0.0f || param > 128.0f) { 209 | VPMT_INVALID_VALUE(context); 210 | } else { 211 | context->materialShininess = param; 212 | } 213 | 214 | break; 215 | 216 | default: 217 | VPMT_INVALID_VALUE(context); 218 | break; 219 | } 220 | } 221 | 222 | void VPMT_ExecMaterialfv(VPMT_Context * context, GLenum face, GLenum pname, const GLfloat * params) 223 | { 224 | if (face != GL_FRONT_AND_BACK) { 225 | VPMT_INVALID_ENUM(context); 226 | return; 227 | } 228 | 229 | if (!params) { 230 | VPMT_INVALID_VALUE(context); 231 | return; 232 | } 233 | 234 | switch (pname) { 235 | case GL_AMBIENT: 236 | VPMT_Vec4Copy(context->materialAmbient, params); 237 | break; 238 | 239 | case GL_DIFFUSE: 240 | VPMT_Vec4Copy(context->materialDiffuse, params); 241 | break; 242 | 243 | case GL_AMBIENT_AND_DIFFUSE: 244 | VPMT_Vec4Copy(context->materialAmbient, params); 245 | VPMT_Vec4Copy(context->materialDiffuse, params); 246 | break; 247 | 248 | case GL_SPECULAR: 249 | VPMT_Vec4Copy(context->materialSpecular, params); 250 | break; 251 | 252 | case GL_EMISSION: 253 | VPMT_Vec4Copy(context->materialEmission, params); 254 | break; 255 | 256 | case GL_SHININESS: 257 | if (*params < 0.0f || *params > 128.0f) { 258 | VPMT_INVALID_VALUE(context); 259 | } else { 260 | context->materialShininess = *params; 261 | } 262 | 263 | break; 264 | 265 | default: 266 | VPMT_INVALID_VALUE(context); 267 | break; 268 | } 269 | } 270 | 271 | void VPMT_ExecShadeModel(VPMT_Context * context, GLenum mode) 272 | { 273 | VPMT_NOT_RENDERING(context); 274 | 275 | switch (mode) { 276 | case GL_FLAT: 277 | case GL_SMOOTH: 278 | context->shadeModel = mode; 279 | break; 280 | 281 | default: 282 | VPMT_INVALID_ENUM(context); 283 | return; 284 | } 285 | } 286 | 287 | void VPMT_LightVertex(VPMT_Context * context, GLfloat * resultColor, 288 | const GLfloat * eyeCoords, const GLfloat * eyeNormal, 289 | const GLfloat * vertexColor) 290 | { 291 | /* light calculation */ 292 | GLsizei index; 293 | 294 | const GLfloat *ambientMaterial; 295 | const GLfloat *diffuseMaterial; 296 | 297 | if (context->colorMaterialEnabled) { 298 | ambientMaterial = vertexColor; 299 | diffuseMaterial = vertexColor; 300 | } else { 301 | ambientMaterial = context->materialAmbient; 302 | diffuseMaterial = context->materialDiffuse; 303 | } 304 | 305 | /* alpha is always determined by alpha of diffuse material color */ 306 | resultColor[3] = diffuseMaterial[3]; 307 | 308 | VPMT_Vec3Copy(resultColor, context->materialEmission); 309 | VPMT_Vec3MulAdd(resultColor, ambientMaterial, context->lightModelAmbient, resultColor); 310 | 311 | for (index = 0; index < VPMT_MAX_LIGHTS; ++index) { 312 | if (context->lightEnabled[index]) { 313 | GLfloat dotProduct = VPMT_Vec3Dot(context->lightDirection[index], eyeNormal); 314 | 315 | VPMT_Vec3MulAdd(resultColor, ambientMaterial, context->lightAmbient[index], 316 | resultColor); 317 | 318 | if (dotProduct > 0.0f) { 319 | VPMT_Vec3 scaledMaterial; 320 | 321 | VPMT_Vec3Scale(scaledMaterial, diffuseMaterial, dotProduct); 322 | VPMT_Vec3MulAdd(resultColor, context->lightDiffuse[index], scaledMaterial, 323 | resultColor); 324 | 325 | dotProduct = VPMT_Vec3Dot(context->lightHighlightDirection[index], eyeNormal); 326 | 327 | if (dotProduct > 0.0f) { 328 | /* add the specular component */ 329 | GLfloat factor = VPMT_POWF(dotProduct, context->materialShininess); 330 | VPMT_Vec3Scale(scaledMaterial, context->materialSpecular, factor); 331 | VPMT_Vec3MulAdd(resultColor, context->lightSpecular[index], scaledMaterial, 332 | resultColor); 333 | } 334 | } 335 | } 336 | } 337 | 338 | /* clamp result to [0, 1] */ 339 | VPMT_Vec4Clamp(resultColor, resultColor); 340 | } 341 | 342 | /* $Id: light.c 74 2008-11-23 07:25:12Z hmwill $ */ 343 | -------------------------------------------------------------------------------- /lib/matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Matrix manipulation functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_MATRIX_H 14 | #define VPMT_MATRIX_H 15 | 16 | #include "util.h" 17 | 18 | typedef GLfloat VPMT_Matrix[16]; 19 | 20 | void VPMT_MatrixFrustumf(GLfloat * frustum, GLfloat left, GLfloat right, GLfloat bottom, 21 | GLfloat top, GLfloat zNear, GLfloat zFar); 22 | void VPMT_MatrixOrthof(GLfloat * ortho, GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, 23 | GLfloat zNear, GLfloat zFar); 24 | void VPMT_MatrixRotatef(GLfloat * rotate, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); 25 | void VPMT_MatrixScalef(GLfloat * scale, GLfloat x, GLfloat y, GLfloat z); 26 | void VPMT_MatrixTranslatef(GLfloat * translate, GLfloat x, GLfloat y, GLfloat z); 27 | void VPMT_MatrixInverse3(GLfloat * result, const GLfloat * matrix); 28 | 29 | void VPMT_MatrixTransform4x3(const GLfloat * matrix, GLfloat * result, const GLfloat * vector); 30 | void VPMT_MatrixTransform3x3(const GLfloat * matrix, GLfloat * result, const GLfloat * vector); 31 | void VPMT_MatrixTransform4x4(const GLfloat * matrix, GLfloat * result, const GLfloat * vector); 32 | 33 | 34 | /* 35 | ** Stack of transformation matrices data structure 36 | */ 37 | typedef struct VPMT_MatrixStack { 38 | VPMT_Matrix *base; /* pointer to base of stack array */ 39 | GLsizei size; /* max. number of stack entries */ 40 | GLsizei current; /* pointer to current top of stack */ 41 | } VPMT_MatrixStack; 42 | 43 | void VPMT_MatrixStackInitialize(VPMT_MatrixStack * stack, VPMT_Matrix * base, GLsizei size); 44 | void VPMT_MatrixStackLoadIdentity(VPMT_MatrixStack * stack); 45 | void VPMT_MatrixStackLoadMatrixf(VPMT_MatrixStack * stack, const GLfloat * matrix); 46 | void VPMT_MatrixStackMultMatrixf(VPMT_MatrixStack * stack, const GLfloat * matrix); 47 | GLboolean VPMT_MatrixStackPushMatrix(VPMT_MatrixStack * stack); 48 | GLboolean VPMT_MatrixStackPopMatrix(VPMT_MatrixStack * stack); 49 | 50 | #endif 51 | 52 | /* $Id: matrix.h 74 2008-11-23 07:25:12Z hmwill $ */ 53 | -------------------------------------------------------------------------------- /lib/platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Platform-specific Declarations and Definitions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | 16 | void *VPMT_Malloc(VPMT_Size_t size) 17 | { 18 | return malloc(size); 19 | } 20 | 21 | void *VPMT_ReAlloc(void * ptr, VPMT_Size_t size) 22 | { 23 | return realloc(ptr, size); 24 | } 25 | 26 | void VPMT_Free(void *ptr) 27 | { 28 | free(ptr); 29 | } 30 | 31 | typedef struct DebugHeader { 32 | int magic; 33 | VPMT_Size_t size; 34 | const char *filename; 35 | int line; 36 | } DebugHeader; 37 | 38 | #define MAGIC 0x12345678 39 | 40 | void *VPMT_MallocDebug(VPMT_Size_t size, const char *filename, int line) 41 | { 42 | VPMT_Size_t total = size + sizeof(DebugHeader); 43 | void *node = malloc(total); 44 | 45 | if (node) { 46 | DebugHeader *header = node; 47 | 48 | header->magic = MAGIC; 49 | header->size = size; 50 | header->filename = filename; 51 | header->line = line; 52 | 53 | return header + 1; 54 | } else { 55 | return NULL; 56 | } 57 | } 58 | 59 | void *VPMT_ReAllocDebug(void * ptr, VPMT_Size_t size, const char *filename, int line) 60 | { 61 | VPMT_Size_t total = size + sizeof(DebugHeader); 62 | void * node; 63 | 64 | if (ptr) { 65 | DebugHeader *header = ((DebugHeader *) ptr) - 1; 66 | 67 | if (header->magic != MAGIC) { 68 | fprintf(stderr, "VPMT_REALLOC of invalid node %p at line %d in %s\n", ptr, line, filename); 69 | return realloc(ptr, size); 70 | } else { 71 | fprintf(stderr, "VPMT_REALLOC of valid node %p at line %d in %s. " 72 | "Allocation [size: %d, file: %s, line: %d]\n", ptr, line, filename, 73 | header->size, header->filename, header->line); 74 | } 75 | } else { 76 | fprintf(stderr, "VPMT_REALLOC of NULL node at line %d in %s\n", line, filename); 77 | return VPMT_MallocDebug(size, filename, line); 78 | } 79 | 80 | node = realloc(((DebugHeader *) ptr) - 1, total); 81 | 82 | if (node) { 83 | DebugHeader *header = node; 84 | 85 | header->magic = MAGIC; 86 | header->size = size; 87 | header->filename = filename; 88 | header->line = line; 89 | 90 | return header + 1; 91 | } else { 92 | return NULL; 93 | } 94 | } 95 | 96 | void VPMT_FreeDebug(void *ptr, const char *filename, int line) 97 | { 98 | if (ptr) { 99 | DebugHeader *header = ((DebugHeader *) ptr) - 1; 100 | 101 | if (header->magic != MAGIC) { 102 | fprintf(stderr, "VPMT_FREE of invalid node %p at line %d in %s\n", ptr, line, filename); 103 | free(ptr); 104 | } else { 105 | fprintf(stderr, "VPMT_FREE of valid node %p at line %d in %s. " 106 | "Allocation [size: %d, file: %s, line: %d]\n", ptr, line, filename, 107 | header->size, header->filename, header->line); 108 | free(header); 109 | } 110 | } else { 111 | fprintf(stderr, "VPMT_FREE of NULL node at line %d in %s\n", line, filename); 112 | } 113 | } 114 | 115 | /* $Id: platform.c 74 2008-11-23 07:25:12Z hmwill $ */ 116 | -------------------------------------------------------------------------------- /lib/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Platform-specific Declarations and Definitions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_PLATFORM_H 14 | #define VPMT_PLATFORM_H 15 | 16 | #include 17 | 18 | /* 19 | ** ------------------------------------------------------------------------- 20 | ** Not all platform compilers support inline functions 21 | ** ------------------------------------------------------------------------- 22 | */ 23 | 24 | #if defined(_MSC_VER) || defined(__GNUC__) 25 | # define VPMT_INLINE __inline 26 | #else 27 | # define VPMT_INLINE 28 | #endif 29 | 30 | /* 31 | ** ------------------------------------------------------------------------- 32 | ** Not all platform runtimes support single precision math functions 33 | ** ------------------------------------------------------------------------- 34 | */ 35 | 36 | #if defined(_WIN32_WCE) 37 | # define VPMT_EMULATE_FLOAT_MATH 38 | #endif 39 | 40 | /* 41 | ** ------------------------------------------------------------------------- 42 | ** Provide memory management debug helper functions 43 | ** ------------------------------------------------------------------------- 44 | */ 45 | 46 | typedef size_t VPMT_Size_t; 47 | 48 | void *VPMT_Malloc(VPMT_Size_t size); 49 | void *VPMT_ReAlloc(void * ptr, VPMT_Size_t size); 50 | void VPMT_Free(void *ptr); 51 | 52 | void *VPMT_MallocDebug(VPMT_Size_t size, const char *filename, int line); 53 | void *VPMT_ReAllocDebug(void * ptr, VPMT_Size_t size, const char *filename, int line); 54 | void VPMT_FreeDebug(void *ptr, const char *filename, int line); 55 | 56 | #if defined(VPMT_MEM_DEBUG) 57 | # define VPMT_MALLOC(size) VPMT_MallocDebug(size, __FILE__, __LINE__) 58 | #define VPMT_REALLOC(ptr, size) VPMT_ReAllocDebug(ptr, size, __FILE__, __LINE__) 59 | # define VPMT_FREE(ptr) VPMT_FreeDebug(ptr, __FILE__, __LINE__) 60 | #else 61 | # define VPMT_MALLOC(size) VPMT_Malloc(size) 62 | # define VPMT_REALLOC(ptr, size) VPMT_ReAlloc(ptr, size) 63 | # define VPMT_FREE(ptr) VPMT_Free(ptr) 64 | #endif 65 | 66 | #endif 67 | 68 | /* $Id: platform.h 74 2008-11-23 07:25:12Z hmwill $ */ 69 | -------------------------------------------------------------------------------- /lib/raster.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Rasterization state functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "raster.h" 17 | 18 | /* 19 | ** ------------------------------------------------------------------------- 20 | ** Exported API entry points - Points 21 | ** ------------------------------------------------------------------------- 22 | */ 23 | 24 | void VPMT_ExecPointSize(VPMT_Context * context, GLfloat size) 25 | { 26 | VPMT_NOT_RENDERING(context); 27 | 28 | if (size <= 0.0f) { 29 | VPMT_INVALID_VALUE(context); 30 | return; 31 | } 32 | 33 | context->pointSize = size; 34 | } 35 | 36 | /* 37 | ** ------------------------------------------------------------------------- 38 | ** Exported API entry points - Lines 39 | ** ------------------------------------------------------------------------- 40 | */ 41 | 42 | void VPMT_ExecLineStipple(VPMT_Context * context, GLint factor, GLushort pattern) 43 | { 44 | VPMT_NOT_RENDERING(context); 45 | 46 | context->lineStippleRepeat = factor < 1 ? 1 : factor > 256 ? 256 : factor; 47 | context->lineStipplePattern = pattern & 0xffff; 48 | } 49 | 50 | void VPMT_ExecLineWidth(VPMT_Context * context, GLfloat width) 51 | { 52 | VPMT_NOT_RENDERING(context); 53 | 54 | if (width <= 0.0f) { 55 | VPMT_INVALID_VALUE(context); 56 | return; 57 | } 58 | 59 | context->lineWidth = width; 60 | } 61 | 62 | /* 63 | ** ------------------------------------------------------------------------- 64 | ** Exported API entry points - Polygons 65 | ** ------------------------------------------------------------------------- 66 | */ 67 | 68 | void VPMT_ExecGetPolygonStipple(VPMT_Context * context, GLubyte * mask) 69 | { 70 | GLsizei row, column; 71 | GLubyte *src; 72 | 73 | VPMT_NOT_RENDERING(context); 74 | 75 | if (!mask) { 76 | VPMT_INVALID_VALUE(context); 77 | return; 78 | } 79 | 80 | src = context->polygonStipple.bytes; 81 | 82 | for (row = 0; row < 32; ++row) { 83 | for (column = 0; column < 4; ++column) { 84 | *mask++ = *src++; 85 | } 86 | 87 | if (context->packAlignment == 8) { 88 | mask += 4; 89 | } 90 | } 91 | } 92 | 93 | void VPMT_ExecPolygonOffset(VPMT_Context * context, GLfloat factor, GLfloat units) 94 | { 95 | VPMT_NOT_RENDERING(context); 96 | 97 | context->polygonOffsetFactor = factor; 98 | context->polygonOffsetUnit = units; 99 | } 100 | 101 | void VPMT_ExecPolygonStipple(VPMT_Context * context, const GLubyte * mask) 102 | { 103 | GLsizei row, column; 104 | GLubyte *dest; 105 | VPMT_NOT_RENDERING(context); 106 | 107 | if (!mask) { 108 | VPMT_INVALID_VALUE(context); 109 | return; 110 | } 111 | 112 | dest = context->polygonStipple.bytes; 113 | 114 | for (row = 0; row < 32; ++row) { 115 | for (column = 0; column < 4; ++column) { 116 | *dest++ = *mask++; 117 | } 118 | 119 | if (context->unpackAlignment == 8) { 120 | mask += 4; 121 | } 122 | } 123 | } 124 | 125 | void VPMT_RasterPrepareInterpolants(VPMT_Context * context) 126 | { 127 | GLsizei index; 128 | GLuint rasterInterpolants = 0u; 129 | GLboolean needsInvW = GL_FALSE; 130 | GLboolean needsColor = GL_TRUE; 131 | 132 | if (context->depthTestEnabled || (context->depthBits != 0 && context->depthWriteMask)) { 133 | rasterInterpolants |= VPMT_RasterInterpolateDepth; 134 | } 135 | 136 | for (index = 0; index < VPMT_MAX_TEX_UNITS; ++index) { 137 | if (context->texUnits[index].enabled && 138 | context->texUnits[index].boundTexture && !context->texUnits[index].incomplete) { 139 | rasterInterpolants |= VPMT_RasterInterpolateTexCoord0 << index; 140 | 141 | if (VPMT_Texture2DIsMipmap(context->texUnits[index].boundTexture)) { 142 | rasterInterpolants |= VPMT_RasterInterpolateRho0 << index; 143 | } 144 | 145 | needsInvW = GL_TRUE; 146 | needsColor &= VPMT_TexImageUnitUsesBaseColor(&context->texUnits[index]); 147 | } 148 | } 149 | 150 | if (needsInvW) { 151 | rasterInterpolants |= VPMT_RasterInterpolateInvW; 152 | } 153 | 154 | if (needsColor) { 155 | rasterInterpolants |= VPMT_RasterInterpolateColor; 156 | } 157 | 158 | context->rasterInterpolants = rasterInterpolants; 159 | } 160 | 161 | /* $Id: raster.c 74 2008-11-23 07:25:12Z hmwill $ */ 162 | -------------------------------------------------------------------------------- /lib/raster.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Rasterizer functions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_RASTER_H 14 | #define VPMT_RASTER_H 15 | 16 | #include "context.h" 17 | 18 | typedef enum { 19 | VPMT_RasterInterpolateDepth = 1, 20 | VPMT_RasterInterpolateInvW = (1 << 1), 21 | VPMT_RasterInterpolateColor = (1 << 2), 22 | VPMT_RasterInterpolateFog = (1 << 3), 23 | VPMT_RasterInterpolateTexCoord0 = (1 << 4), 24 | VPMT_RasterInterpolateTexCoord1 = (1 << 5), 25 | VPMT_RasterInterpolateTexCoord2 = (1 << 6), 26 | VPMT_RasterInterpolateTexCoord3 = (1 << 7), 27 | VPMT_RasterInterpolateRho0 = (1 << 8), 28 | VPMT_RasterInterpolateRho1 = (1 << 9), 29 | VPMT_RasterInterpolateRho2 = (1 << 10), 30 | VPMT_RasterInterpolateRho3 = (1 << 11) 31 | } VPMT_RasterInterpolants; 32 | 33 | void VPMT_RasterPrepareInterpolants(VPMT_Context * context); 34 | 35 | void VPMT_RasterPreparePoint(VPMT_Context * context); 36 | void VPMT_RasterPrepareLine(VPMT_Context * context); 37 | void VPMT_RasterPrepareTriangle(VPMT_Context * context); 38 | void VPMT_LineStippleReset(VPMT_Context * context); 39 | 40 | void VPMT_RasterQuadAA(VPMT_Context * context, const VPMT_RasterVertex * a, 41 | const VPMT_RasterVertex * b, const VPMT_RasterVertex * c, 42 | const VPMT_RasterVertex * d); 43 | 44 | #endif 45 | 46 | /* $Id: raster.h 74 2008-11-23 07:25:12Z hmwill $ */ 47 | -------------------------------------------------------------------------------- /lib/rasterpt.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Rasterizer functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "raster.h" 17 | #include "frame.h" 18 | 19 | #define PRECISION VPMT_SUBPIXEL_BITS 20 | #define HALF (1 << (PRECISION - 1)) 21 | #define ONE (1 << PRECISION) 22 | 23 | /* 24 | ** ------------------------------------------------------------------------- 25 | ** Actual rasterizer code 26 | ** ------------------------------------------------------------------------- 27 | */ 28 | 29 | static void RasterPointAliased(VPMT_Context * context, const VPMT_RasterVertex * a) 30 | { 31 | VPMT_Color4ub rgba; 32 | GLuint xctr, yctr, xmin, ymin, xmax, ymax, x, y; 33 | GLuint size = context->integerPointSize; 34 | GLuint depth = (GLuint) a->depth; 35 | VPMT_FrameBuffer fb; 36 | 37 | /* 1. determine the center, xmin, max, ymin, ymax */ 38 | if (size & 1) { 39 | /* odd point size */ 40 | xctr = a->screenCoords[0] >> VPMT_SUBPIXEL_BITS; 41 | yctr = a->screenCoords[1] >> VPMT_SUBPIXEL_BITS; 42 | 43 | xmin = xctr - (size >> 1); 44 | ymin = yctr - (size >> 1); 45 | 46 | xmax = xctr + (size >> 1) + 1; 47 | ymax = yctr + (size >> 1) + 1; 48 | } else { 49 | /* even point size */ 50 | xctr = (a->screenCoords[0] + HALF) >> VPMT_SUBPIXEL_BITS; 51 | yctr = (a->screenCoords[1] + HALF) >> VPMT_SUBPIXEL_BITS; 52 | 53 | xmin = xctr - (size >> 1); 54 | ymin = yctr - (size >> 1); 55 | 56 | xmax = xctr + (size >> 1); 57 | ymax = yctr + (size >> 1); 58 | } 59 | 60 | /* clip to scissor */ 61 | xmin = VPMT_MAX(xmin, (GLuint) context->activeSurfaceRect.origin[0]); 62 | ymin = VPMT_MAX(ymin, (GLuint) context->activeSurfaceRect.origin[1]); 63 | xmax = 64 | VPMT_MIN(xmax, 65 | (GLuint) context->activeSurfaceRect.origin[0] + 66 | context->activeSurfaceRect.size.width); 67 | ymax = 68 | VPMT_MIN(ymax, 69 | (GLuint) context->activeSurfaceRect.origin[1] + 70 | context->activeSurfaceRect.size.height); 71 | 72 | /* 2. lookup texture color */ 73 | rgba = 74 | VPMT_TexImageUnitsExecute(context->texUnits, VPMT_ConvertVec4ToColor4us(a->rgba), 75 | a->texCoords, NULL); 76 | 77 | VPMT_FrameBufferInit(&fb, context->writeSurface); 78 | VPMT_FrameBufferMove(&fb, xmin, ymin); 79 | 80 | /* 3. Generate fragment for each (xmin, ymin) <= (x, y) < (xmax, ymax) */ 81 | for (y = ymin; y < ymax; ++y) { 82 | VPMT_FrameBufferSave(&fb); 83 | 84 | for (x = xmin; x < xmax; ++x) { 85 | VPMT_Fragment(context, &fb, rgba, depth); 86 | VPMT_FrameBufferStepX(&fb); 87 | } 88 | 89 | VPMT_FrameBufferRestore(&fb); 90 | VPMT_FrameBufferStepY(&fb); 91 | } 92 | } 93 | 94 | /* as value 0..256 */ 95 | static GLuint PointCoverage(GLsizei xbase, GLsizei ybase, GLsizei sqrRadius) 96 | { 97 | GLint x, y; 98 | GLuint count = 0; 99 | 100 | /* we are sampling at every second sub-pixel */ 101 | for (y = 0; y < ONE; y += 2) { 102 | for (x = 0; x < ONE; x += 2) { 103 | if ((x + xbase) * (x + xbase) + (y + ybase) * (y + ybase) < sqrRadius) { 104 | ++count; 105 | } 106 | } 107 | } 108 | 109 | return (count * 256) / (HALF * HALF); 110 | } 111 | 112 | static void RasterPointAA(VPMT_Context * context, const VPMT_RasterVertex * a) 113 | { 114 | VPMT_Color4ub rgba; 115 | GLuint xctr, yctr, xmin, ymin, xmax, ymax, x, y; 116 | GLsizei xbase0, ybase, xbase1; 117 | GLuint aaPointSize = context->aaPointSize, sqrPointSize = aaPointSize * aaPointSize; 118 | GLubyte alpha; 119 | GLuint depth = (GLuint) a->depth; 120 | VPMT_FrameBuffer fb; 121 | 122 | /* 1. determine the center, xmin, max, ymin, ymax */ 123 | xctr = a->screenCoords[0]; 124 | yctr = a->screenCoords[1]; 125 | 126 | xmin = (xctr - aaPointSize) >> VPMT_SUBPIXEL_BITS; 127 | ymin = (yctr - aaPointSize) >> VPMT_SUBPIXEL_BITS; 128 | xmax = (xctr + aaPointSize + ONE - 1) >> VPMT_SUBPIXEL_BITS; 129 | ymax = (yctr + aaPointSize + ONE - 1) >> VPMT_SUBPIXEL_BITS; 130 | 131 | /* clip to scissor */ 132 | xmin = VPMT_MAX(xmin, (GLuint) context->activeSurfaceRect.origin[0]); 133 | ymin = VPMT_MAX(ymin, (GLuint) context->activeSurfaceRect.origin[1]); 134 | xmax = 135 | VPMT_MIN(xmax, 136 | (GLuint) context->activeSurfaceRect.origin[0] + 137 | context->activeSurfaceRect.size.width); 138 | ymax = 139 | VPMT_MIN(ymax, 140 | (GLuint) context->activeSurfaceRect.origin[1] + 141 | context->activeSurfaceRect.size.height); 142 | 143 | /* offset by one sub-pixel */ 144 | xbase0 = (xmin << VPMT_SUBPIXEL_BITS) - xctr + 1; 145 | ybase = (ymin << VPMT_SUBPIXEL_BITS) - yctr + 1; 146 | 147 | /* 2. lookup texture color */ 148 | rgba = 149 | VPMT_TexImageUnitsExecute(context->texUnits, VPMT_ConvertVec4ToColor4us(a->rgba), 150 | a->texCoords, NULL); 151 | alpha = rgba.alpha; 152 | 153 | VPMT_FrameBufferInit(&fb, context->writeSurface); 154 | VPMT_FrameBufferMove(&fb, xmin, ymin); 155 | 156 | /* 3. Generate fragment for each (xmin, ymin) <= (x, y) < (xmax, ymax) */ 157 | for (y = ymin; y < ymax; ++y, ybase += ONE) { 158 | VPMT_FrameBufferSave(&fb); 159 | xbase1 = xbase0; 160 | 161 | for (x = xmin; x < xmax; ++x, xbase1 += ONE) { 162 | GLuint coverage = PointCoverage(xbase1, ybase, sqrPointSize); 163 | 164 | if (coverage > 0.0f) { 165 | rgba.alpha = (coverage * alpha) >> 8; 166 | VPMT_Fragment(context, &fb, rgba, depth); 167 | } 168 | 169 | VPMT_FrameBufferStepX(&fb); 170 | } 171 | 172 | VPMT_FrameBufferRestore(&fb); 173 | VPMT_FrameBufferStepY(&fb); 174 | } 175 | } 176 | 177 | void VPMT_RasterPreparePoint(VPMT_Context * context) 178 | { 179 | if (context->pointSmoothEnabled) { 180 | GLint size = VPMT_ROUND(context->pointSize * ONE); 181 | 182 | if (size <= 0) { 183 | size = 1; 184 | } else if (size > (GLint) VPMT_MAX_POINT_SIZE * ONE) { 185 | size = (GLint) VPMT_MAX_POINT_SIZE *ONE; 186 | } 187 | 188 | context->aaPointSize = size; 189 | context->rasterPoint = RasterPointAA; 190 | } else { 191 | GLint size = VPMT_ROUND(context->pointSize); 192 | 193 | if (size <= 0) { 194 | size = 1; 195 | } else if (size > (GLint) VPMT_MAX_POINT_SIZE) { 196 | size = (GLint) VPMT_MAX_POINT_SIZE; 197 | } 198 | 199 | context->integerPointSize = size; 200 | context->rasterPoint = RasterPointAliased; 201 | } 202 | } 203 | 204 | /* $Id: rasterpt.c 74 2008-11-23 07:25:12Z hmwill $ */ 205 | -------------------------------------------------------------------------------- /lib/system.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** System-specific Declarations and Definitions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_SYSTEM_H 14 | #define VPMT_SYSTEM_H 15 | 16 | 17 | void VPMT_ClearInstructionCache(void * start, GLsizei size); 18 | 19 | void * VPMT_AllocateExecutableSegment(GLsizei size); 20 | void VPMT_DeallocateExecutableSegment(void * ptr, GLsizei size); 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /lib/tex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Texture State Functions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_TEX_H 14 | #define VPMT_TEX_H 15 | 16 | #include "image.h" 17 | 18 | typedef struct VPMT_Texture2D { 19 | GLuint name; 20 | VPMT_Image2D *mipmaps[VPMT_MAX_MIPMAP_LEVEL + 1]; 21 | 22 | #if GL_EXT_paletted_texture 23 | VPMT_Image1D *palette; /* a palette is an image of height 1 */ 24 | #endif 25 | 26 | GLenum texWrapS; 27 | GLenum texWrapT; 28 | GLenum texMinFilter; 29 | GLenum texMagFilter; 30 | GLsizei maxMipmapLevel; 31 | GLboolean complete; 32 | GLboolean validated; 33 | } VPMT_Texture2D; 34 | 35 | VPMT_Texture2D *VPMT_Texture2DAllocate(GLuint name); 36 | void VPMT_Texture2DDeallocate(VPMT_Texture2D * texture); 37 | 38 | void VPMT_Texture2DValidate(VPMT_Texture2D * texture); 39 | GLboolean VPMT_ValidateTextureFormat(GLenum format); 40 | GLboolean VPMT_ValidateInternalFormat(GLenum format); 41 | GLboolean VPMT_ValidateNonIndexedTextureFormat(GLenum format); 42 | 43 | GLboolean VPMT_Texture2DIsMipmap(const VPMT_Texture2D * texture); 44 | 45 | #endif 46 | 47 | /* $Id: tex.h 74 2008-11-23 07:25:12Z hmwill $ */ 48 | -------------------------------------------------------------------------------- /lib/texenv.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Texture Environment Functions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | 17 | /* 18 | ** ------------------------------------------------------------------------- 19 | ** Exported API entry points 20 | ** ------------------------------------------------------------------------- 21 | */ 22 | 23 | void VPMT_ExecActiveTexture(VPMT_Context * context, GLenum texture) 24 | { 25 | GLint index; 26 | 27 | VPMT_NOT_RENDERING(context); 28 | 29 | if (texture < GL_TEXTURE0 || texture > GL_TEXTURE31) { 30 | VPMT_INVALID_ENUM(context); 31 | return; 32 | } 33 | 34 | index = texture - GL_TEXTURE0; 35 | 36 | if (index >= VPMT_MAX_TEX_UNITS) { 37 | VPMT_INVALID_VALUE(context); 38 | return; 39 | } 40 | 41 | context->activeTexture = texture; 42 | context->activeTextureIndex = index; 43 | } 44 | 45 | void VPMT_ExecBindTexture(VPMT_Context * context, GLenum target, GLuint name) 46 | { 47 | VPMT_Texture2D *texture; 48 | 49 | VPMT_NOT_RENDERING(context); 50 | 51 | texture = VPMT_HashTableFind(&context->textures, name); 52 | 53 | if (!texture) { 54 | texture = VPMT_Texture2DAllocate(name); 55 | 56 | if (!texture) { 57 | VPMT_OUT_OF_MEMORY(context); 58 | return; 59 | } 60 | 61 | if (!VPMT_HashTableInsert(&context->textures, name, texture)) { 62 | VPMT_Texture2DDeallocate(texture); 63 | VPMT_OUT_OF_MEMORY(context); 64 | return; 65 | } 66 | } 67 | 68 | context->texUnits[context->activeTextureIndex].boundTexture = texture; 69 | context->texUnits[context->activeTextureIndex].boundTexture2D = texture->name; 70 | } 71 | 72 | void VPMT_ExecGetTexEnvfv(VPMT_Context * context, GLenum target, GLenum pname, GLfloat * params) 73 | { 74 | VPMT_NOT_RENDERING(context); 75 | 76 | if (target != GL_TEXTURE_ENV) { 77 | VPMT_INVALID_ENUM(context); 78 | return; 79 | } 80 | 81 | if (!params) { 82 | VPMT_INVALID_VALUE(context); 83 | return; 84 | } 85 | 86 | switch (pname) { 87 | case GL_TEXTURE_ENV_COLOR: 88 | VPMT_Vec4Copy(params, context->texUnits[context->activeTextureIndex].envColor); 89 | break; 90 | 91 | default: 92 | VPMT_INVALID_ENUM(context); 93 | return; 94 | } 95 | } 96 | 97 | void VPMT_ExecGetTexEnviv(VPMT_Context * context, GLenum target, GLenum pname, GLint * params) 98 | { 99 | VPMT_NOT_RENDERING(context); 100 | 101 | if (target != GL_TEXTURE_ENV) { 102 | VPMT_INVALID_ENUM(context); 103 | return; 104 | } 105 | 106 | if (!params) { 107 | VPMT_INVALID_VALUE(context); 108 | return; 109 | } 110 | 111 | switch (pname) { 112 | case GL_TEXTURE_ENV_MODE: 113 | *params = context->texUnits[context->activeTextureIndex].envMode; 114 | break; 115 | 116 | default: 117 | VPMT_INVALID_VALUE(context); 118 | return; 119 | } 120 | } 121 | 122 | void VPMT_ExecTexEnvfv(VPMT_Context * context, GLenum target, GLenum pname, const GLfloat * params) 123 | { 124 | VPMT_NOT_RENDERING(context); 125 | 126 | if (target != GL_TEXTURE_ENV) { 127 | VPMT_INVALID_ENUM(context); 128 | return; 129 | } 130 | 131 | if (!params) { 132 | VPMT_INVALID_VALUE(context); 133 | return; 134 | } 135 | 136 | switch (pname) { 137 | case GL_TEXTURE_ENV_COLOR: 138 | VPMT_Vec4Copy(context->texUnits[context->activeTextureIndex].envColor, params); 139 | context->texUnits[context->activeTextureIndex].envColor4us = 140 | VPMT_ConvertVec4ToColor4us(context->texUnits[context->activeTextureIndex].envColor); 141 | break; 142 | 143 | default: 144 | VPMT_INVALID_VALUE(context); 145 | return; 146 | } 147 | } 148 | 149 | void VPMT_ExecTexEnvi(VPMT_Context * context, GLenum target, GLenum pname, GLint param) 150 | { 151 | VPMT_NOT_RENDERING(context); 152 | 153 | if (target != GL_TEXTURE_ENV) { 154 | VPMT_INVALID_ENUM(context); 155 | return; 156 | } 157 | 158 | switch (pname) { 159 | case GL_TEXTURE_ENV_MODE: 160 | if (param != GL_MODULATE && param != GL_REPLACE && param != GL_DECAL && 161 | param != GL_BLEND && param != GL_ADD) { 162 | VPMT_INVALID_VALUE(context); 163 | return; 164 | } 165 | 166 | context->texUnits[context->activeTextureIndex].envMode = param; 167 | break; 168 | 169 | default: 170 | VPMT_INVALID_VALUE(context); 171 | return; 172 | } 173 | } 174 | 175 | /* $Id: texenv.c 74 2008-11-23 07:25:12Z hmwill $ */ 176 | -------------------------------------------------------------------------------- /lib/texunit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Texture Image Unit Functions 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_TEXUNIT_H 14 | #define VPMT_TEXUNIT_H 15 | 16 | #include "tex.h" 17 | 18 | typedef struct VPMT_TexImageUnit VPMT_TexImageUnit; 19 | 20 | typedef VPMT_Color4us(*VPMT_Sampler2DFunc) (const VPMT_TexImageUnit * unit, const GLfloat * coords, 21 | GLfloat rho); 22 | 23 | struct VPMT_TexImageUnit { 24 | /* external state */ 25 | VPMT_Vec4 envColor; 26 | VPMT_Color4us envColor4us; 27 | VPMT_Texture2D *boundTexture; 28 | GLint boundTexture2D; /* shortcut for state queries */ 29 | GLenum envMode; 30 | GLboolean enabled, incomplete; 31 | 32 | /* internal state */ 33 | VPMT_Sampler2DFunc sampler2D; 34 | VPMT_Image2DSampleFunc imageMinSampler; 35 | VPMT_Image2DSampleFunc imageMagSampler; 36 | GLfloat magMinSwitchOver; 37 | }; 38 | 39 | void VPMT_TexImageUnitsInit(VPMT_TexImageUnit units[VPMT_MAX_TEX_UNITS], 40 | VPMT_Texture2D * texture2d); 41 | 42 | VPMT_Color4ub VPMT_TexImageUnitsExecute(VPMT_TexImageUnit units[VPMT_MAX_TEX_UNITS], 43 | VPMT_Color4us baseColor, const VPMT_Vec2 coords[], 44 | const GLfloat * rho); 45 | 46 | GLboolean VPMT_TexImageUnitUsesBaseColor(const VPMT_TexImageUnit * unit); 47 | 48 | void VPMT_TexImageUnitsPrepare(VPMT_TexImageUnit units[VPMT_MAX_TEX_UNITS]); 49 | 50 | #endif 51 | 52 | /* $Id: texunit.h 74 2008-11-23 07:25:12Z hmwill $ */ 53 | -------------------------------------------------------------------------------- /lib/util.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Internal utility functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "util.h" 16 | 17 | void VPMT_IntersectRect(VPMT_Rect * result, const VPMT_Rect * a, const VPMT_Rect * b) 18 | { 19 | result->origin[0] = VPMT_MAX(a->origin[0], b->origin[0]); 20 | result->origin[1] = VPMT_MAX(a->origin[1], b->origin[1]); 21 | 22 | result->size.width = VPMT_MIN(a->size.width + a->origin[0], b->size.width + b->origin[0]) 23 | - result->origin[0]; 24 | 25 | result->size.height = VPMT_MIN(a->size.height + a->origin[1], b->size.height + b->origin[1]) 26 | - result->origin[1]; 27 | } 28 | 29 | /* $Id: util.c 74 2008-11-23 07:25:12Z hmwill $ */ 30 | -------------------------------------------------------------------------------- /lib/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** Internal utility functions. 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef VPMT_UTIL_H 14 | #define VPMT_UTIL_H 15 | 16 | #define VPMT_MIN(a, b) ((a) < (b) ? (a) : (b)) 17 | #define VPMT_MAX(a, b) ((a) > (b) ? (a) : (b)) 18 | #define VPMT_CLAMP(a) ((a) > 1.0f ? 1.0f : (a) < 0.0f ? 0.0f : (a)) 19 | #define VPMT_SELECT(sel, a, b) ((sel) ? (a) : (b)) 20 | #define VPMT_ROUND(a) ((GLint) ((a) + 0.5f)) 21 | #define VPMT_FRAC(a) ((a) - floorf(a)) 22 | #define VPMT_ALIGN(v, a) ((((v) + (a) - 1) / (a)) * (a)) 23 | #define VPMT_ELEMENTSOF(a) ((sizeof(a)/sizeof((a)[0]))) 24 | 25 | #if defined(VPMT_EMULATE_FLOAT_MATH) 26 | # define VPMT_SINF(a) ((GLfloat) sin(a)) 27 | # define VPMT_COSF(a) ((GLfloat) cos(a)) 28 | # define VPMT_POWF(a, b) ((GLfloat) pow(a, b)) 29 | #else 30 | # define VPMT_SINF(a) sinf(a) 31 | # define VPMT_COSF(a) cosf(a) 32 | # define VPMT_POWF(a, b) powf(a, b) 33 | #endif 34 | 35 | #define VPMT_UBYTE_TO_FLOAT(a) (((a) & 0xff) * (1.0f/255.0f)) 36 | #define VPMT_BYTE_TO_FLOAT(a) ((((a) & 0xff) * 2 + 1) * (1.0f/255.0f)) 37 | #define VPMT_FLOAT_TO_UBYTE(a) (((GLuint)(511 * VPMT_CLAMP(a))) >> 1) 38 | 39 | typedef GLint VPMT_Vec2i[2]; 40 | typedef GLint VPMT_Vec3i[3]; 41 | typedef GLint VPMT_Vec4i[4]; 42 | 43 | #define VPMT_V2I_MIN(r, a, b) \ 44 | ((r)[0] = VPMT_MIN((a)[0], (b)[0]), \ 45 | (r)[1] = VPMT_MIN((a)[1], (b)[1])) 46 | 47 | #define VPMT_V2I_MAX(r, a, b) \ 48 | ((r)[0] = VPMT_MAX((a)[0], (b)[0]), \ 49 | (r)[1] = VPMT_MAX((a)[1], (b)[1])) 50 | 51 | typedef GLfloat VPMT_Vec2[2]; 52 | typedef GLfloat VPMT_Vec3[3]; 53 | typedef GLfloat VPMT_Vec4[4]; 54 | 55 | #define VPMT_Vec2Copy(r, a)\ 56 | do { (r)[0] = (a)[0]; (r)[1] = (a)[1]; } while(GL_FALSE) 57 | 58 | #define VPMT_Vec3Copy(r, a)\ 59 | do { (r)[0] = (a)[0]; (r)[1] = (a)[1]; (r)[2] = (a)[2]; } while(GL_FALSE) 60 | 61 | #define VPMT_Vec4Copy(r, a)\ 62 | do { (r)[0] = (a)[0]; (r)[1] = (a)[1]; (r)[2] = (a)[2]; (r)[3] = (a)[3]; } while(GL_FALSE) 63 | 64 | #define VPMT_Vec2Cast(r, a, t)\ 65 | do { (r)[0] = (t)(a)[0]; (r)[1] = (t)(a)[1]; } while(GL_FALSE) 66 | 67 | #define VPMT_Vec3Cast(r, a, t)\ 68 | do { (r)[0] = (t)(a)[0]; (r)[1] = (t)(a)[1]; (r)[2] = (t)(a)[2]; } while(GL_FALSE) 69 | 70 | #define VPMT_Vec4Cast(r, a, t)\ 71 | do { (r)[0] = (t)(a)[0]; (r)[1] = (t)(a)[1]; (r)[2] = (t)(a)[2]; (r)[3] = (t)(a)[3]; } while(GL_FALSE) 72 | 73 | #define VPMT_Vec2Clamp(r, a)\ 74 | do { (r)[0] = VPMT_CLAMP((a)[0]); (r)[1] = VPMT_CLAMP((a)[1]); } while(GL_FALSE) 75 | 76 | #define VPMT_Vec3Clamp(r, a)\ 77 | do { (r)[0] = VPMT_CLAMP((a)[0]); (r)[1] = VPMT_CLAMP((a)[1]); (r)[2] = VPMT_CLAMP((a)[2]); } while(GL_FALSE) 78 | 79 | #define VPMT_Vec4Clamp(r, a)\ 80 | do { (r)[0] = VPMT_CLAMP((a)[0]); (r)[1] = VPMT_CLAMP((a)[1]); \ 81 | (r)[2] = VPMT_CLAMP((a)[2]); (r)[3] = VPMT_CLAMP((a)[3]); } while(GL_FALSE) 82 | 83 | #define VPMT_MatrixCopy(r, a)\ 84 | do { GLsizei idx; for (idx = 0; idx < 16; ++idx) (r)[idx] = (a)[idx]; } while(GL_FALSE) 85 | 86 | #define VPMT_Vec2Add(r, a, b)\ 87 | do { (r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; } while(GL_FALSE) 88 | 89 | #define VPMT_Vec3Add(r, a, b)\ 90 | do { (r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; (r)[2] = (a)[2] + (b)[2]; } while(GL_FALSE) 91 | 92 | #define VPMT_Vec4Add(r, a, b)\ 93 | do { (r)[0] = (a)[0] + (b)[0]; (r)[1] = (a)[1] + (b)[1]; (r)[2] = (a)[2] + (b)[2]; (r)[3] = (a)[3] + (b)[3]; } while(GL_FALSE) 94 | 95 | #define VPMT_Vec2Sub(r, a, b)\ 96 | do { (r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; } while(GL_FALSE) 97 | 98 | #define VPMT_Vec3Sub(r, a, b)\ 99 | do { (r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; (r)[2] = (a)[2] - (b)[2]; } while(GL_FALSE) 100 | 101 | #define VPMT_Vec4Sub(r, a, b)\ 102 | do { (r)[0] = (a)[0] - (b)[0]; (r)[1] = (a)[1] - (b)[1]; (r)[2] = (a)[2] - (b)[2]; (r)[3] = (a)[3] - (b)[3]; } while(GL_FALSE) 103 | 104 | #define VPMT_Vec2Mul(r, a, b)\ 105 | do { (r)[0] = (a)[0] * (b)[0]; (r)[1] = (a)[1] * (b)[1]; } while(GL_FALSE) 106 | 107 | #define VPMT_Vec3Mul(r, a, b)\ 108 | do { (r)[0] = (a)[0] * (b)[0]; (r)[1] = (a)[1] * (b)[1]; (r)[2] = (a)[2] * (b)[2]; } while(GL_FALSE) 109 | 110 | #define VPMT_Vec4Mul(r, a, b)\ 111 | do { (r)[0] = (a)[0] * (b)[0]; (r)[1] = (a)[1] * (b)[1]; (r)[2] = (a)[2] * (b)[2]; (r)[3] = (a)[3] * (b)[3]; } while(GL_FALSE) 112 | 113 | #define VPMT_Vec2Scale(r, a, b)\ 114 | do { (r)[0] = (a)[0] * (b); (r)[1] = (a)[1] * (b); } while(GL_FALSE) 115 | 116 | #define VPMT_Vec3Scale(r, a, b)\ 117 | do { (r)[0] = (a)[0] * (b); (r)[1] = (a)[1] * (b); (r)[2] = (a)[2] * (b); } while(GL_FALSE) 118 | 119 | #define VPMT_Vec4Scale(r, a, b)\ 120 | do { (r)[0] = (a)[0] * (b); (r)[1] = (a)[1] * (b); (r)[2] = (a)[2] * (b); (r)[3] = (a)[3] * (b); } while(GL_FALSE) 121 | 122 | #define VPMT_Vec2MulAdd(r, a, b, c)\ 123 | do { (r)[0] = (a)[0] * (b)[0] + (c)[0]; (r)[1] = (a)[1] * (b)[1] + (c)[1]; } while(GL_FALSE) 124 | 125 | #define VPMT_Vec3MulAdd(r, a, b, c)\ 126 | do { (r)[0] = (a)[0] * (b)[0] + (c)[0]; (r)[1] = (a)[1] * (b)[1] + (c)[1]; \ 127 | (r)[2] = (a)[2] * (b)[2] + (c)[2]; } while(GL_FALSE) 128 | 129 | #define VPMT_Vec4MulAdd(r, a, b, c)\ 130 | do { (r)[0] = (a)[0] * (b)[0] + (c)[0]; (r)[1] = (a)[1] * (b)[1] + (c)[1]; \ 131 | (r)[2] = (a)[2] * (b)[2] + (c)[2]; (r)[3] = (a)[3] * (b)[3] + (c)[3]; } while(GL_FALSE) 132 | 133 | #define VPMT_Vec2ScaleAdd(r, a, b, c)\ 134 | do { (r)[0] = (a)[0] * (b) + (c)[0]; (r)[1] = (a)[1] * (b) + (c)[1]; } while(GL_FALSE) 135 | 136 | #define VPMT_Vec3ScaleAdd(r, a, b, c)\ 137 | do { (r)[0] = (a)[0] * (b) + (c)[0]; (r)[1] = (a)[1] * (b) + (c)[1]; \ 138 | (r)[2] = (a)[2] * (b) + (c)[2]; } while(GL_FALSE) 139 | 140 | #define VPMT_Vec4ScaleAdd(r, a, b, c)\ 141 | do { (r)[0] = (a)[0] * (b) + (c)[0]; (r)[1] = (a)[1] * (b) + (c)[1]; \ 142 | (r)[2] = (a)[2] * (b) + (c)[2]; (r)[3] = (a)[3] * (b) + (c)[3]; } while(GL_FALSE) 143 | 144 | #define VPMT_Vec3AddBy2(r, a, b)\ 145 | do { (r)[0] = (a)[0] + ((b)[0] >> 1); (r)[1] = (a)[1] + ((b)[1] >> 1); (r)[2] = (a)[2] + ((b)[2] >> 1); } while(GL_FALSE) 146 | 147 | #define VPMT_Vec4AddBy2(r, a, b)\ 148 | do { (r)[0] = (a)[0] + ((b)[0] >> 1); (r)[1] = (a)[1] + ((b)[1] >> 1); (r)[2] = (a)[2] + ((b)[2] >> 1); (r)[3] = (a)[3] + ((b)[3] >> 1); } while(GL_FALSE) 149 | 150 | #define VPMT_Vec4AddBy4(r, a, b)\ 151 | do { (r)[0] = (a)[0] + ((b)[0] >> 2); (r)[1] = (a)[1] + ((b)[1] >> 2); (r)[2] = (a)[2] + ((b)[2] >> 2); (r)[3] = (a)[3] + ((b)[3] >> 2); } while(GL_FALSE) 152 | 153 | #define VPMT_Vec4SubBy2(r, a, b)\ 154 | do { (r)[0] = (a)[0] - ((b)[0] >> 1); (r)[1] = (a)[1] - ((b)[1] >> 1); (r)[2] = (a)[2] - ((b)[2] >> 1); (r)[3] = (a)[3] - ((b)[3] >> 1); } while(GL_FALSE) 155 | 156 | #define VPMT_Vec4SubBy4(r, a, b)\ 157 | do { (r)[0] = (a)[0] - ((b)[0] >> 2); (r)[1] = (a)[1] - ((b)[1] >> 2); (r)[2] = (a)[2] - ((b)[2] >> 2); (r)[3] = (a)[3] - ((b)[3] >> 2); } while(GL_FALSE) 158 | 159 | #define VPMT_Vec2Lerp(r, a, b, c)\ 160 | do { (r)[0] = (a)[0] + ((b)[0] - (a)[0]) * (c); \ 161 | (r)[1] = (a)[1] + ((b)[1] - (a)[1]) * (c); } while(GL_FALSE); 162 | 163 | #define VPMT_Vec4Lerp(r, a, b, c)\ 164 | do { (r)[0] = (a)[0] + ((b)[0] - (a)[0]) * (c); \ 165 | (r)[1] = (a)[1] + ((b)[1] - (a)[1]) * (c); \ 166 | (r)[2] = (a)[2] + ((b)[2] - (a)[2]) * (c); \ 167 | (r)[3] = (a)[3] + ((b)[3] - (a)[3]) * (c); } while(GL_FALSE); 168 | 169 | #define VPMT_Vec2Dot(a, b) ((a)[0] * (b)[0] + (a)[1] * (b)[1]) 170 | #define VPMT_Vec3Dot(a, b) ((a)[0] * (b)[0] + (a)[1] * (b)[1] + (a)[2] * (b)[2]) 171 | #define VPMT_Vec4Dot(a, b) ((a)[0] * (b)[0] + (a)[1] * (b)[1] + (a)[2] * (b)[2] + (a)[3] * (b)[3]) 172 | 173 | typedef GLboolean VPMT_Vec2b[2]; 174 | typedef GLboolean VPMT_Vec3b[3]; 175 | typedef GLboolean VPMT_Vec4b[4]; 176 | 177 | typedef struct VPMT_Size { 178 | GLsizei width, height; 179 | } VPMT_Size; 180 | 181 | typedef struct VPMT_Sizef { 182 | GLfloat width, height; 183 | } VPMT_Sizef; 184 | 185 | typedef struct VPMT_Rect { 186 | VPMT_Vec2i origin; 187 | VPMT_Size size; 188 | } VPMT_Rect; 189 | 190 | void VPMT_IntersectRect(VPMT_Rect * result, const VPMT_Rect * a, const VPMT_Rect * b); 191 | 192 | typedef struct VPMT_Rectf { 193 | VPMT_Vec2 origin; 194 | VPMT_Sizef size; 195 | } VPMT_Rectf; 196 | 197 | typedef struct VPMT_Color4ub { 198 | GLubyte red; 199 | GLubyte green; 200 | GLubyte blue; 201 | GLubyte alpha; 202 | } VPMT_Color4ub; 203 | 204 | typedef struct VPMT_Color4us { 205 | GLushort red; 206 | GLushort green; 207 | GLushort blue; 208 | GLushort alpha; 209 | } VPMT_Color4us; 210 | 211 | typedef struct VPMT_Color4f { 212 | GLfloat red; 213 | GLfloat green; 214 | GLfloat blue; 215 | GLfloat alpha; 216 | } VPMT_Color4f; 217 | 218 | static VPMT_INLINE GLubyte VPMT_UByteMul(GLubyte a, GLubyte b) 219 | { 220 | GLushort c = (GLushort) a * (GLushort) b; 221 | 222 | return (c + (c >> 8) + 1) >> 8; 223 | } 224 | 225 | static VPMT_INLINE GLushort VPMT_UShortMul(GLushort a, GLushort b) 226 | { 227 | GLuint c = (GLuint) a * (GLuint) b; 228 | 229 | return (c + (c >> 16) + 1) >> 16; 230 | } 231 | 232 | static VPMT_INLINE GLubyte VPMT_UByteMul256(GLubyte a, GLuint b) 233 | { 234 | return ((a * b) + 0x80u) >> 8; 235 | } 236 | 237 | static VPMT_INLINE VPMT_Color4ub VPMT_ConvertVec4ToColor4ub(const GLfloat * rgba) 238 | { 239 | VPMT_Color4ub retval; 240 | 241 | retval.red = (GLubyte) (0xff * VPMT_CLAMP(rgba[0])); 242 | retval.green = (GLubyte) (0xff * VPMT_CLAMP(rgba[1])); 243 | retval.blue = (GLubyte) (0xff * VPMT_CLAMP(rgba[2])); 244 | retval.alpha = (GLubyte) (0xff * VPMT_CLAMP(rgba[3])); 245 | 246 | return retval; 247 | } 248 | 249 | static VPMT_INLINE VPMT_Color4us VPMT_ConvertVec4ToColor4us(const GLfloat * rgba) 250 | { 251 | VPMT_Color4us retval; 252 | 253 | retval.red = (GLushort) (0xffff * VPMT_CLAMP(rgba[0])); 254 | retval.green = (GLushort) (0xffff * VPMT_CLAMP(rgba[1])); 255 | retval.blue = (GLushort) (0xffff * VPMT_CLAMP(rgba[2])); 256 | retval.alpha = (GLushort) (0xffff * VPMT_CLAMP(rgba[3])); 257 | 258 | return retval; 259 | } 260 | 261 | static VPMT_INLINE VPMT_Color4us VPMT_ConvertColor4ubToColor4us(VPMT_Color4ub color) 262 | { 263 | VPMT_Color4us retval; 264 | 265 | retval.red = color.red | (color.red << 8); 266 | retval.green = color.green | (color.green << 8); 267 | retval.blue = color.blue | (color.blue << 8); 268 | retval.alpha = color.alpha | (color.alpha << 8); 269 | 270 | return retval; 271 | } 272 | 273 | static VPMT_INLINE VPMT_Color4ub VPMT_ConvertColor4usToColor4ub(VPMT_Color4us color) 274 | { 275 | VPMT_Color4ub retval; 276 | 277 | retval.red = (GLubyte) (color.red >> 8); 278 | retval.green = (GLubyte) (color.green >> 8); 279 | retval.blue = (GLubyte) (color.blue >> 8); 280 | retval.alpha = (GLubyte) (color.alpha >> 8); 281 | 282 | return retval; 283 | } 284 | 285 | static VPMT_INLINE GLuint VPMT_Color255To256(GLubyte color) 286 | { 287 | return color + (color >> 7); 288 | } 289 | 290 | 291 | 292 | #endif 293 | 294 | /* $Id: util.h 74 2008-11-23 07:25:12Z hmwill $ */ 295 | -------------------------------------------------------------------------------- /lib/vgl.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** SDL bindings as interim solution until proper EGL implementation in place 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "exec.h" 17 | #include "GL/vgl.h" 18 | 19 | 20 | GLAPI GLboolean APIENTRY vglInitialize(void) 21 | { 22 | return VPMT_Initialize(); 23 | } 24 | 25 | GLAPI GLboolean APIENTRY vglTerminate(void) 26 | { 27 | VPMT_Terminate(); 28 | return GL_TRUE; 29 | } 30 | 31 | GLAPI void (APIENTRY * vglGetProcAddress(const char *procname)) () { 32 | 33 | if (!procname) { 34 | return NULL; 35 | } 36 | #if GL_EXT_paletted_texture 37 | if (!strcmp("glColorSubTableEXT", procname)) { 38 | return (void (APIENTRY *) ()) &glColorSubTableEXT; 39 | } 40 | 41 | if (!strcmp("glColorTableEXT", procname)) { 42 | return (void (APIENTRY *) ()) &glColorTableEXT; 43 | } 44 | 45 | if (!strcmp("glGetColorTableEXT", procname)) { 46 | return (void (APIENTRY *) ()) &glGetColorTableEXT; 47 | } 48 | 49 | if (!strcmp("glGetColorTableParameterivEXT", procname)) { 50 | return (void (APIENTRY *) ()) &glGetColorTableParameterivEXT; 51 | } 52 | #endif 53 | 54 | return NULL; 55 | } 56 | 57 | GLAPI GLboolean APIENTRY vglDestroySurface(VGL_Surface surface) 58 | { 59 | VPMT_Surface *wrapper = (VPMT_Surface *) surface; 60 | wrapper->vtbl->release(wrapper); 61 | 62 | return GL_TRUE; 63 | } 64 | 65 | GLAPI GLboolean APIENTRY vglMakeCurrent(VGL_Surface draw, VGL_Surface read) 66 | { 67 | VPMT_Surface *drawWrapper = (VPMT_Surface *) draw; 68 | VPMT_Surface *readWrapper = (VPMT_Surface *) read; 69 | 70 | return VPMT_MakeCurrent(drawWrapper, readWrapper); 71 | } 72 | 73 | GLAPI VGL_Surface APIENTRY vglGetReadSurface(void) 74 | { 75 | return (VGL_Surface) VPMT_GetReadSurface(); 76 | } 77 | 78 | GLAPI VGL_Surface APIENTRY vglGetWriteSurface(void) 79 | { 80 | return (VGL_Surface) VPMT_GetWriteSurface(); 81 | } 82 | 83 | /* $Id: vgl.c 74 2008-11-23 07:25:12Z hmwill $ */ 84 | -------------------------------------------------------------------------------- /lib/vglsdl.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** ------------------------------------------------------------------------- 3 | ** Vincent SC 1.0 Rendering Library 4 | ** 5 | ** SDL Surface Bindings 6 | ** 7 | ** Copyright (C) 2008 Vincent Pervasive Media Technologies, LLC. 8 | ** 9 | ** Licensed under the Artistic License 2.0. 10 | ** ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "common.h" 14 | #include "GL/gl.h" 15 | #include "context.h" 16 | #include "exec.h" 17 | #include "GL/vgl.h" 18 | #include 19 | 20 | typedef struct SdlSurfaceWrapper { 21 | VPMT_Surface surface; 22 | SDL_Surface *sdlSurface; 23 | } SdlSurfaceWrapper; 24 | 25 | static void AddrefSurface(struct VPMT_Surface *surface) 26 | { 27 | SdlSurfaceWrapper *wrapper = (SdlSurfaceWrapper *) surface; 28 | 29 | ++wrapper->surface.refcount; 30 | } 31 | 32 | static void ReleaseSurface(struct VPMT_Surface *surface) 33 | { 34 | SdlSurfaceWrapper *wrapper = (SdlSurfaceWrapper *) surface; 35 | 36 | if (--wrapper->surface.refcount == 0) { 37 | if (wrapper->sdlSurface) { 38 | SDL_FreeSurface(wrapper->sdlSurface); 39 | } 40 | 41 | if (wrapper->surface.depthStencilBuffer) { 42 | VPMT_FREE(wrapper->surface.depthStencilBuffer); 43 | } 44 | 45 | VPMT_FREE(wrapper); 46 | } 47 | } 48 | 49 | static void LockSurface(VPMT_Context * context, struct VPMT_Surface *surface) 50 | { 51 | SdlSurfaceWrapper *wrapper = (SdlSurfaceWrapper *) surface; 52 | VPMT_Rect surfaceRect; 53 | 54 | if (SDL_MUSTLOCK(wrapper->sdlSurface) && !wrapper->sdlSurface->locked) { 55 | SDL_LockSurface(wrapper->sdlSurface); 56 | } 57 | 58 | wrapper->surface.image.data = 59 | wrapper->sdlSurface->h <= 1 ? 60 | (GLubyte *) wrapper->sdlSurface->pixels : 61 | (GLubyte *) wrapper->sdlSurface->pixels + 62 | wrapper->sdlSurface->pitch * (wrapper->sdlSurface->h - 1); 63 | 64 | surfaceRect.origin[0] = wrapper->sdlSurface->clip_rect.x; 65 | surfaceRect.origin[1] = wrapper->sdlSurface->clip_rect.y; 66 | surfaceRect.size.width = wrapper->sdlSurface->clip_rect.w; 67 | surfaceRect.size.height = wrapper->sdlSurface->clip_rect.h; 68 | 69 | VPMT_UpdateActiveSurfaceRect(context, &surfaceRect); 70 | } 71 | 72 | static void UnlockSurface(VPMT_Context * context, struct VPMT_Surface *surface) 73 | { 74 | SdlSurfaceWrapper *wrapper = (SdlSurfaceWrapper *) surface; 75 | 76 | if (SDL_MUSTLOCK(wrapper->sdlSurface) && wrapper->sdlSurface->locked) { 77 | SDL_UnlockSurface(wrapper->sdlSurface); 78 | } 79 | 80 | wrapper->surface.image.data = NULL; 81 | } 82 | 83 | static VPMT_SurfaceVtbl Vtbl = { 84 | &AddrefSurface, 85 | &ReleaseSurface, 86 | &LockSurface, 87 | &UnlockSurface 88 | }; 89 | 90 | GLAPI VGL_Surface APIENTRY 91 | vglCreateSurface(GLsizei width, GLsizei height, GLenum format, GLenum type, GLenum depthStencilType) 92 | { 93 | SdlSurfaceWrapper *wrapper = NULL; 94 | 95 | const VPMT_PixelFormat *pixelFormat = VPMT_GetPixelFormat(format, type); 96 | 97 | const VPMT_DepthStencilFormat *depthStencilFormat = 98 | VPMT_GetDepthStencilFormat(depthStencilType); 99 | 100 | union { 101 | GLubyte rgba[4]; 102 | GLuint mask; 103 | } translate; 104 | 105 | GLuint redMask, greenMask, blueMask, alphaMask; 106 | 107 | /* only allow 32-bit RGBA format at this point; can extend later */ 108 | if (format != GL_RGBA || 109 | (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_INT_8_8_8_8 110 | && type != GL_UNSIGNED_INT_8_8_8_8_REV) || !pixelFormat || !depthStencilFormat) { 111 | return NULL; 112 | } 113 | 114 | translate.mask = 0, translate.rgba[0] = 0xffu, redMask = translate.mask; 115 | translate.mask = 0, translate.rgba[1] = 0xffu, greenMask = translate.mask; 116 | translate.mask = 0, translate.rgba[2] = 0xffu, blueMask = translate.mask; 117 | translate.mask = 0, translate.rgba[3] = 0 /*xffu */ , alphaMask = translate.mask; 118 | 119 | wrapper = VPMT_MALLOC(sizeof(SdlSurfaceWrapper)); 120 | 121 | if (wrapper) { 122 | GLubyte *baseAddr; 123 | 124 | wrapper->surface.vtbl = &Vtbl; 125 | wrapper->sdlSurface = NULL; 126 | wrapper->surface.depthStencilBuffer = NULL; 127 | 128 | wrapper->sdlSurface = 129 | SDL_CreateRGBSurface(0, width, height, pixelFormat->bits, 130 | redMask, greenMask, blueMask, alphaMask); 131 | 132 | if (!wrapper->sdlSurface) { 133 | goto error; 134 | } 135 | 136 | if (height <= 1) { 137 | baseAddr = wrapper->sdlSurface->pixels; 138 | } else { 139 | baseAddr = (GLubyte *) wrapper->sdlSurface->pixels + 140 | (height - 1) * wrapper->sdlSurface->pitch; 141 | } 142 | 143 | VPMT_Image2DInit(&wrapper->surface.image, pixelFormat, 144 | -(GLsizei) wrapper->sdlSurface->pitch, width, height, baseAddr); 145 | 146 | wrapper->surface.depthStencilFormat = depthStencilFormat; 147 | wrapper->surface.depthStencilBuffer = 148 | VPMT_MALLOC(height * width * (depthStencilFormat->bits / VPMT_BITS_PER_BYTE)); 149 | 150 | if (!wrapper->surface.depthStencilBuffer) { 151 | goto error; 152 | } 153 | 154 | wrapper->surface.refcount = 1; 155 | 156 | return (VGL_Surface) & wrapper->surface; 157 | } 158 | 159 | error: 160 | if (wrapper) { 161 | if (wrapper->sdlSurface) { 162 | SDL_FreeSurface(wrapper->sdlSurface); 163 | } 164 | 165 | if (wrapper->surface.depthStencilBuffer) { 166 | VPMT_FREE(wrapper->surface.depthStencilBuffer); 167 | } 168 | 169 | VPMT_FREE(wrapper); 170 | } 171 | 172 | return NULL; 173 | } 174 | 175 | GLAPI GLboolean APIENTRY vglSwapBuffers(SDL_Surface * display, VGL_Surface surface) 176 | { 177 | SdlSurfaceWrapper *wrapper = (SdlSurfaceWrapper *) surface; 178 | 179 | if (!SDL_BlitSurface(wrapper->sdlSurface, NULL, display, NULL) && !SDL_Flip(display)) { 180 | return GL_TRUE; 181 | } else { 182 | return GL_FALSE; 183 | } 184 | } 185 | 186 | /* $Id: vglsdl.c 74 2008-11-23 07:25:12Z hmwill $ */ 187 | -------------------------------------------------------------------------------- /vin_sc.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib", "lib\lib.vcproj", "{07668918-DF10-46EE-AC64-40505BC023A1}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "demo\demo.vcproj", "{A078E761-2BD8-4A56-8CAB-F91533E3B71D}" 6 | ProjectSection(ProjectDependencies) = postProject 7 | {07668918-DF10-46EE-AC64-40505BC023A1} = {07668918-DF10-46EE-AC64-40505BC023A1} 8 | EndProjectSection 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Mixed Platforms = Debug|Mixed Platforms 13 | Debug|Pocket PC 2003 (ARMV4) = Debug|Pocket PC 2003 (ARMV4) 14 | Debug|Smartphone 2003 (ARMV4) = Debug|Smartphone 2003 (ARMV4) 15 | Debug|Win32 = Debug|Win32 16 | Debug|Win32CE = Debug|Win32CE 17 | Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 18 | Release|Mixed Platforms = Release|Mixed Platforms 19 | Release|Pocket PC 2003 (ARMV4) = Release|Pocket PC 2003 (ARMV4) 20 | Release|Smartphone 2003 (ARMV4) = Release|Smartphone 2003 (ARMV4) 21 | Release|Win32 = Release|Win32 22 | Release|Win32CE = Release|Win32CE 23 | Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) = Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I) 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Mixed Platforms.ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 27 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Mixed Platforms.Build.0 = Debug|imx313dsmobilitysdk (ARMV4I) 28 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Mixed Platforms.Deploy.0 = Debug|imx313dsmobilitysdk (ARMV4I) 29 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 30 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 31 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Win32.ActiveCfg = Debug|Win32 32 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Win32.Build.0 = Debug|Win32 33 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Win32CE.ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 34 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Win32CE.Build.0 = Debug|imx313dsmobilitysdk (ARMV4I) 35 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Win32CE.Deploy.0 = Debug|imx313dsmobilitysdk (ARMV4I) 36 | {07668918-DF10-46EE-AC64-40505BC023A1}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 37 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Mixed Platforms.ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 38 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Mixed Platforms.Build.0 = Release|imx313dsmobilitysdk (ARMV4I) 39 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Mixed Platforms.Deploy.0 = Release|imx313dsmobilitysdk (ARMV4I) 40 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 41 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 42 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Win32.ActiveCfg = Release|Win32 43 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Win32.Build.0 = Release|Win32 44 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Win32CE.ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 45 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Win32CE.Build.0 = Release|imx313dsmobilitysdk (ARMV4I) 46 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Win32CE.Deploy.0 = Release|imx313dsmobilitysdk (ARMV4I) 47 | {07668918-DF10-46EE-AC64-40505BC023A1}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 48 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Mixed Platforms.ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 49 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Mixed Platforms.Build.0 = Debug|imx313dsmobilitysdk (ARMV4I) 50 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Mixed Platforms.Deploy.0 = Debug|imx313dsmobilitysdk (ARMV4I) 51 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Pocket PC 2003 (ARMV4).ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 52 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Smartphone 2003 (ARMV4).ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 53 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Win32.ActiveCfg = Debug|Win32 54 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Win32.Build.0 = Debug|Win32 55 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Win32CE.ActiveCfg = Debug|imx313dsmobilitysdk (ARMV4I) 56 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Win32CE.Build.0 = Debug|imx313dsmobilitysdk (ARMV4I) 57 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Win32CE.Deploy.0 = Debug|imx313dsmobilitysdk (ARMV4I) 58 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 59 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Mixed Platforms.ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 60 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Mixed Platforms.Build.0 = Release|imx313dsmobilitysdk (ARMV4I) 61 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Mixed Platforms.Deploy.0 = Release|imx313dsmobilitysdk (ARMV4I) 62 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Pocket PC 2003 (ARMV4).ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 63 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Smartphone 2003 (ARMV4).ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 64 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Win32.ActiveCfg = Release|Win32 65 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Win32.Build.0 = Release|Win32 66 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Win32CE.ActiveCfg = Release|imx313dsmobilitysdk (ARMV4I) 67 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Win32CE.Build.0 = Release|imx313dsmobilitysdk (ARMV4I) 68 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Win32CE.Deploy.0 = Release|imx313dsmobilitysdk (ARMV4I) 69 | {A078E761-2BD8-4A56-8CAB-F91533E3B71D}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 70 | EndGlobalSection 71 | GlobalSection(SolutionProperties) = preSolution 72 | HideSolutionNode = FALSE 73 | EndGlobalSection 74 | EndGlobal 75 | --------------------------------------------------------------------------------