Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

getprocaddress.c 128KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738
  1. /*
  2. * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included
  12. * in all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. /*
  22. * Test that glXGetProcAddress works.
  23. */
  24. #define GLX_GLXEXT_PROTOTYPES
  25. #include <X11/Xlib.h>
  26. #include <X11/Xutil.h>
  27. #include <GL/gl.h>
  28. #include <GL/glx.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32. #include <math.h>
  33. typedef void (*generic_func)();
  34. #define EQUAL(X, Y) (fabs((X) - (Y)) < 0.001)
  35. /* This macro simplifies the task of querying an extension function
  36. * pointer and checking to see whether it resolved.
  37. */
  38. #define DECLARE_GLFUNC_PTR(name,type) \
  39. type name = (type) glXGetProcAddressARB((const GLubyte *) "gl" #name)
  40. /********************************************************************
  41. * Generic helper functions used by the test functions.
  42. */
  43. static void CheckGLError(int line, const char *file, const char *function)
  44. {
  45. int errorCode;
  46. glFinish();
  47. errorCode = glGetError();
  48. if (errorCode == GL_NO_ERROR) return;
  49. while (errorCode != GL_NO_ERROR) {
  50. fprintf(stderr, "OpenGL error 0x%x (%s) at line %d of file %s in function %s()\n",
  51. errorCode,
  52. errorCode == GL_INVALID_VALUE? "GL_INVALID_VALUE":
  53. errorCode == GL_INVALID_ENUM? "GL_INVALID_ENUM":
  54. errorCode == GL_INVALID_OPERATION? "GL_INVALID_OPERATION":
  55. errorCode == GL_STACK_OVERFLOW? "GL_STACK_OVERFLOW":
  56. errorCode == GL_STACK_UNDERFLOW? "GL_STACK_UNDERFLOW":
  57. errorCode == GL_OUT_OF_MEMORY? "GL_OUT_OF_MEMORY":
  58. "unknown",
  59. line, file, function);
  60. errorCode = glGetError();
  61. }
  62. fflush(stderr);
  63. }
  64. static GLboolean
  65. compare_bytes(const char *errorLabel, GLuint expectedSize,
  66. const GLubyte *expectedData, GLuint actualSize, const GLubyte *actualData)
  67. {
  68. int i;
  69. if (expectedSize == actualSize &&
  70. memcmp(expectedData, actualData, actualSize) == 0) {
  71. /* All is well */
  72. return GL_TRUE;
  73. }
  74. /* Trouble; we don't match. Print out why. */
  75. fprintf(stderr, "%s: actual data is not as expected\n", errorLabel);
  76. for (i = 0; i <= 1; i++) {
  77. const GLubyte *ptr;
  78. int size;
  79. char *label;
  80. int j;
  81. switch(i) {
  82. case 0:
  83. label = "expected";
  84. size = expectedSize;
  85. ptr = expectedData;
  86. break;
  87. case 1:
  88. label = " actual";
  89. size = actualSize;
  90. ptr = actualData;
  91. break;
  92. }
  93. fprintf(stderr, " %s: size %d: {", label, size);
  94. for (j = 0; j < size; j++) {
  95. fprintf(stderr, "%s0x%02x", j > 0 ? ", " : "", ptr[j]);
  96. }
  97. fprintf(stderr, "}\n");
  98. }
  99. /* We fail if the data is unexpected. */
  100. return GL_FALSE;
  101. }
  102. static GLboolean
  103. compare_ints(const char *errorLabel, GLuint expectedSize,
  104. const GLint *expectedData, GLuint actualSize, const GLint *actualData)
  105. {
  106. int i;
  107. if (expectedSize == actualSize &&
  108. memcmp(expectedData, actualData, actualSize*sizeof(*expectedData)) == 0) {
  109. /* All is well */
  110. return GL_TRUE;
  111. }
  112. /* Trouble; we don't match. Print out why. */
  113. fprintf(stderr, "%s: actual data is not as expected\n", errorLabel);
  114. for (i = 0; i <= 1; i++) {
  115. const GLint *ptr;
  116. int size;
  117. char *label;
  118. int j;
  119. switch(i) {
  120. case 0:
  121. label = "expected";
  122. size = expectedSize;
  123. ptr = expectedData;
  124. break;
  125. case 1:
  126. label = " actual";
  127. size = actualSize;
  128. ptr = actualData;
  129. break;
  130. }
  131. fprintf(stderr, " %s: size %d: {", label, size);
  132. for (j = 0; j < size; j++) {
  133. fprintf(stderr, "%s%d", j > 0 ? ", " : "", ptr[j]);
  134. }
  135. fprintf(stderr, "}\n");
  136. }
  137. /* We fail if the data is unexpected. */
  138. return GL_FALSE;
  139. }
  140. #define MAX_CONVERTED_VALUES 4
  141. static GLboolean
  142. compare_shorts_to_ints(const char *errorLabel, GLuint expectedSize,
  143. const GLshort *expectedData, GLuint actualSize, const GLint *actualData)
  144. {
  145. int i;
  146. GLint convertedValues[MAX_CONVERTED_VALUES];
  147. if (expectedSize > MAX_CONVERTED_VALUES) {
  148. fprintf(stderr, "%s: too much data [need %d values, have %d values]\n",
  149. errorLabel, expectedSize, MAX_CONVERTED_VALUES);
  150. return GL_FALSE;
  151. }
  152. for (i = 0; i < expectedSize; i++) {
  153. convertedValues[i] = (GLint) expectedData[i];
  154. }
  155. return compare_ints(errorLabel, expectedSize, convertedValues,
  156. actualSize, actualData);
  157. }
  158. static GLboolean
  159. compare_floats(const char *errorLabel, GLuint expectedSize,
  160. const GLfloat *expectedData, GLuint actualSize, const GLfloat *actualData)
  161. {
  162. int i;
  163. if (expectedSize == actualSize &&
  164. memcmp(expectedData, actualData, actualSize*sizeof(*expectedData)) == 0) {
  165. /* All is well */
  166. return GL_TRUE;
  167. }
  168. /* Trouble; we don't match. Print out why. */
  169. fprintf(stderr, "%s: actual data is not as expected\n", errorLabel);
  170. for (i = 0; i <= 1; i++) {
  171. const GLfloat *ptr;
  172. int size;
  173. char *label;
  174. int j;
  175. switch(i) {
  176. case 0:
  177. label = "expected";
  178. size = expectedSize;
  179. ptr = expectedData;
  180. break;
  181. case 1:
  182. label = " actual";
  183. size = actualSize;
  184. ptr = actualData;
  185. break;
  186. }
  187. fprintf(stderr, " %s: size %d: {", label, size);
  188. for (j = 0; j < size; j++) {
  189. fprintf(stderr, "%s%f", j > 0 ? ", " : "", ptr[j]);
  190. }
  191. fprintf(stderr, "}\n");
  192. }
  193. /* We fail if the data is unexpected. */
  194. return GL_FALSE;
  195. }
  196. static GLboolean
  197. compare_doubles(const char *errorLabel, GLuint expectedSize,
  198. const GLdouble *expectedData, GLuint actualSize, const GLdouble *actualData)
  199. {
  200. int i;
  201. if (expectedSize == actualSize ||
  202. memcmp(expectedData, actualData, actualSize*sizeof(*expectedData)) == 0) {
  203. /* All is well */
  204. return GL_TRUE;
  205. }
  206. /* Trouble; we don't match. Print out why. */
  207. fprintf(stderr, "%s: actual data is not as expected\n", errorLabel);
  208. for (i = 0; i <= 1; i++) {
  209. const GLdouble *ptr;
  210. int size;
  211. char *label;
  212. int j;
  213. switch(i) {
  214. case 0:
  215. label = "expected";
  216. size = expectedSize;
  217. ptr = expectedData;
  218. break;
  219. case 1:
  220. label = " actual";
  221. size = actualSize;
  222. ptr = actualData;
  223. break;
  224. }
  225. fprintf(stderr, " %s: size %d: {", label, size);
  226. for (j = 0; j < size; j++) {
  227. fprintf(stderr, "%s%f", j > 0 ? ", " : "", ptr[j]);
  228. }
  229. fprintf(stderr, "}\n");
  230. }
  231. /* We fail if the data is unexpected. */
  232. return GL_FALSE;
  233. }
  234. /********************************************************************
  235. * Functions to assist with GL_ARB_texture_compressiong testing
  236. */
  237. static GLboolean
  238. check_texture_format_supported(GLenum format)
  239. {
  240. GLint numFormats;
  241. GLint *formats;
  242. register int i;
  243. glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numFormats);
  244. formats = malloc(numFormats * sizeof(GLint));
  245. if (formats == NULL) {
  246. fprintf(stderr, "check_texture_format_supported: could not allocate memory for %d GLints\n",
  247. numFormats);
  248. return GL_FALSE;
  249. }
  250. memset(formats, 0, numFormats * sizeof(GLint));
  251. glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB, formats);
  252. for (i = 0; i < numFormats; i++) {
  253. if (formats[i] == format) {
  254. free(formats);
  255. return GL_TRUE;
  256. }
  257. }
  258. /* We didn't find the format we were looking for. Give an error. */
  259. #define FORMAT_NAME(x) (\
  260. x == GL_COMPRESSED_RGB_FXT1_3DFX ? "GL_COMPRESSED_RGB_FXT1_3DFX" : \
  261. x == GL_COMPRESSED_RGBA_FXT1_3DFX ? "GL_COMPRESSED_RGBA_FXT1_3DFX" : \
  262. x == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? "GL_COMPRESSED_RGB_S3TC_DXT1_EXT" : \
  263. x == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ? "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT" : \
  264. x == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ? "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT" : \
  265. x == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ? "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT" : \
  266. x == GL_RGB_S3TC ? "GL_RGB_S3TC" : \
  267. x == GL_RGB4_S3TC ? "GL_RGB4_S3TC" : \
  268. x == GL_RGBA_S3TC ? "GL_RGBA_S3TC" : \
  269. x == GL_RGBA4_S3TC ? "GL_RGBA4_S3TC" : \
  270. "unknown")
  271. fprintf(stderr, "check_texture_format_supported: unsupported format 0x%04x [%s]\n",
  272. format, FORMAT_NAME(format));
  273. fprintf(stderr, "supported formats:");
  274. for (i = 0; i < numFormats; i++) {
  275. fprintf(stderr, " 0x%04x [%s]", formats[i], FORMAT_NAME(formats[i]));
  276. }
  277. fprintf(stderr, "\n");
  278. return GL_FALSE;
  279. }
  280. /* This helper function compresses an RGBA texture and compares it
  281. * against the expected compressed data. It returns GL_TRUE if all
  282. * went as expected, or GL_FALSE in the case of error.
  283. */
  284. static GLboolean
  285. check_texture_compression(const char *message, GLenum dimension,
  286. GLint width, GLint height, GLint depth, const GLubyte *texture,
  287. int expectedCompressedSize, const GLubyte *expectedCompressedData)
  288. {
  289. /* These are the data we query about the texture. */
  290. GLint isCompressed;
  291. GLenum compressedFormat;
  292. GLint compressedSize;
  293. GLubyte *compressedData;
  294. /* We need this function pointer to operate. */
  295. DECLARE_GLFUNC_PTR(GetCompressedTexImageARB, PFNGLGETCOMPRESSEDTEXIMAGEARBPROC);
  296. if (GetCompressedTexImageARB == NULL) {
  297. fprintf(stderr,
  298. "%s: could not query GetCompressedTexImageARB function pointer\n",
  299. message);
  300. return GL_FALSE;
  301. }
  302. /* Verify that we actually have the GL_COMPRESSED_RGBA_S3TC_DXT3_EXT format available. */
  303. if (!check_texture_format_supported(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)) {
  304. return GL_FALSE;
  305. }
  306. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  307. /* Set up the base image, requesting that the GL library compress it. */
  308. switch(dimension) {
  309. case GL_TEXTURE_1D:
  310. glTexImage1D(GL_TEXTURE_1D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  311. width, 0,
  312. GL_RGBA, GL_UNSIGNED_BYTE, texture);
  313. break;
  314. case GL_TEXTURE_2D:
  315. glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  316. width, height, 0,
  317. GL_RGBA, GL_UNSIGNED_BYTE, texture);
  318. break;
  319. case GL_TEXTURE_3D:
  320. glTexImage3D(GL_TEXTURE_3D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  321. width, height, depth, 0,
  322. GL_RGBA, GL_UNSIGNED_BYTE, texture);
  323. break;
  324. default:
  325. fprintf(stderr, "%s: unknown dimension 0x%04x.\n", message, dimension);
  326. return GL_FALSE;
  327. }
  328. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  329. /* Make sure the texture is compressed, and pull it out if it is. */
  330. glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_COMPRESSED_ARB,
  331. &isCompressed);
  332. if (!isCompressed) {
  333. fprintf(stderr, "%s: could not compress GL_COMPRESSED_RGBA_S3TC_DXT3_EXT texture\n",
  334. message);
  335. return GL_FALSE;
  336. }
  337. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  338. glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_INTERNAL_FORMAT,
  339. (GLint *)&compressedFormat);
  340. if (compressedFormat != GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) {
  341. fprintf(stderr, "%s: got internal format 0x%04x, expected GL_COMPRESSED_RGBA_S3TC_DXT3_EXT [0x%04x]\n",
  342. __FUNCTION__, compressedFormat, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
  343. return GL_FALSE;
  344. }
  345. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  346. glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &compressedSize);
  347. compressedData = malloc(compressedSize);
  348. if (compressedData == NULL) {
  349. fprintf(stderr, "%s: could not malloc %d bytes for compressed texture\n",
  350. message, compressedSize);
  351. return GL_FALSE;
  352. }
  353. memset(compressedData, 0, compressedSize);
  354. (*GetCompressedTexImageARB)(dimension, 0, compressedData);
  355. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  356. /* Compare it to the expected compressed data. The compare_bytes()
  357. * call will print out diagnostics in the case of failure.
  358. */
  359. if (!compare_bytes(message,
  360. expectedCompressedSize, expectedCompressedData,
  361. compressedSize, compressedData)) {
  362. free(compressedData);
  363. return GL_FALSE;
  364. }
  365. /* All done. Free our allocated data and return success. */
  366. free(compressedData);
  367. return GL_TRUE;
  368. }
  369. /* We'll use one function to exercise 1D, 2D, and 3D textures. */
  370. /* The test function for compressed 3D texture images requires several
  371. * different function pointers that have to be queried. This function
  372. * gets all the function pointers it needs itself, and so is suitable for
  373. * use to test any and all of the incorporated functions.
  374. */
  375. static GLboolean
  376. exercise_CompressedTextures(GLenum dimension)
  377. {
  378. /* Set up a basic (uncompressed) texture. We're doing a blue/yellow
  379. * checkerboard. The 8x4/32-pixel board is well-suited to S3TC
  380. * compression, which works on 4x4 blocks of pixels.
  381. */
  382. #define B 0,0,255,255
  383. #define Y 255,255,0,255
  384. #define TEXTURE_WIDTH 16
  385. #define TEXTURE_HEIGHT 4
  386. #define TEXTURE_DEPTH 1
  387. static GLubyte texture[TEXTURE_WIDTH*TEXTURE_HEIGHT*TEXTURE_DEPTH*4] = {
  388. B, B, Y, Y, B, B, Y, Y, B, B, Y, Y, B, B, Y, Y,
  389. B, B, Y, Y, B, B, Y, Y, B, B, Y, Y, B, B, Y, Y,
  390. Y, Y, B, B, Y, Y, B, B, Y, Y, B, B, Y, Y, B, B,
  391. Y, Y, B, B, Y, Y, B, B, Y, Y, B, B, Y, Y, B, B,
  392. };
  393. #undef B
  394. #undef Y
  395. GLubyte uncompressedTexture[TEXTURE_WIDTH*TEXTURE_HEIGHT*TEXTURE_DEPTH*4];
  396. /* We'll use this as a texture subimage. */
  397. #define R 255,0,0,255
  398. #define G 0,255,0,255
  399. #define SUBTEXTURE_WIDTH 4
  400. #define SUBTEXTURE_HEIGHT 4
  401. #define SUBTEXTURE_DEPTH 1
  402. static GLubyte subtexture[SUBTEXTURE_WIDTH*SUBTEXTURE_HEIGHT*SUBTEXTURE_DEPTH*4] = {
  403. G, G, R, R,
  404. G, G, R, R,
  405. R, R, G, G,
  406. R, R, G, G,
  407. };
  408. #undef R
  409. #undef G
  410. /* These are the expected compressed textures. (In the case of
  411. * a failed comparison, the test program will print out the
  412. * actual compressed data in a format that can be directly used
  413. * here, if desired.) The brave of heart can calculate the compression
  414. * themselves based on the formulae described at:
  415. * http://en.wikipedia.org/wiki/S3_Texture_Compression
  416. * In a nutshell, each group of 16 bytes encodes a 4x4 texture block.
  417. * The first eight bytes of each group are 4-bit alpha values
  418. * for each of the 16 pixels in the texture block.
  419. * The next four bytes in each group are LSB-first RGB565 colors; the
  420. * first two bytes are identified as the color C0, and the next two
  421. * are the color C1. (Two more colors C2 and C3 will be calculated
  422. * from these, but do not appear in the compression data.) The
  423. * last 4 bytes of the group are sixteen 2-bit indices that, for
  424. * each of the 16 pixels in the texture block, select one of the
  425. * colors C0, C1, C2, or C3.
  426. *
  427. * For example, our blue/yellow checkerboard is made up of
  428. * four identical 4x4 blocks. Each of those blocks will
  429. * be encoded as: eight bytes of 0xff (16 alpha values, each 0xf),
  430. * C0 as the RGB565 color yellow (0xffe0), encoded LSB-first;
  431. * C1 as the RGB565 color blue (0x001f), encoded LSB-first;
  432. * and 4 bytes of 16 2-bit color indices reflecting the
  433. * choice of color for each of the 16 pixels:
  434. * 00, 00, 01, 01, = 0x05
  435. * 00, 00, 01, 01, = 0x05
  436. * 01, 01, 00, 00, = 0x50
  437. * 01, 01, 00, 00, = 0x50
  438. */
  439. static GLubyte compressedTexture[] = {
  440. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  441. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50,
  442. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  443. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50,
  444. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  445. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50,
  446. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  447. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50
  448. };
  449. /* The similar calculations for the 4x4 subtexture are left
  450. * as an exercise for the reader.
  451. */
  452. static GLubyte compressedSubTexture[] = {
  453. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  454. 0x00, 0xf8, 0xe0, 0x07, 0x05, 0x05, 0x50, 0x50,
  455. };
  456. /* The combined texture replaces the initial blue/yellow
  457. * block with the green/red block. (I'd wanted to do
  458. * the more interesting exercise of putting the
  459. * green/red block in the middle of the blue/yellow
  460. * texture, which is a non-trivial replacement, but
  461. * the attempt produces GL_INVALID_OPERATION, showing
  462. * that you can only replace whole blocks of
  463. * subimages with S3TC.) The combined texture looks
  464. * like:
  465. * G G R R B B Y Y B B Y Y B B Y Y
  466. * G G R R B B Y Y B B Y Y B B Y Y
  467. * R R G G Y Y B B Y Y B B Y Y B B
  468. * R R G G Y Y B B Y Y B B Y Y B B
  469. * which encodes just like the green/red block followed
  470. * by 3 copies of the yellow/blue block.
  471. */
  472. static GLubyte compressedCombinedTexture[] = {
  473. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  474. 0x00, 0xf8, 0xe0, 0x07, 0x05, 0x05, 0x50, 0x50,
  475. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  476. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50,
  477. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  478. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50,
  479. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  480. 0xe0, 0xff, 0x1f, 0x00, 0x05, 0x05, 0x50, 0x50
  481. };
  482. /* These are the data we query about the texture. */
  483. GLint queryIsCompressed;
  484. GLenum queryCompressedFormat;
  485. GLint queryCompressedSize;
  486. GLubyte queryCompressedData[sizeof(compressedTexture)];
  487. /* Query the function pointers we need. We actually won't need most
  488. * of these (the "dimension" parameter dictates whether we're testing
  489. * 1D, 2D, or 3D textures), but we'll have them all ready just in case.
  490. */
  491. DECLARE_GLFUNC_PTR(GetCompressedTexImageARB, PFNGLGETCOMPRESSEDTEXIMAGEARBPROC);
  492. DECLARE_GLFUNC_PTR(CompressedTexImage3DARB, PFNGLCOMPRESSEDTEXIMAGE3DARBPROC);
  493. DECLARE_GLFUNC_PTR(CompressedTexSubImage3DARB, PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC);
  494. DECLARE_GLFUNC_PTR(CompressedTexImage2DARB, PFNGLCOMPRESSEDTEXIMAGE2DARBPROC);
  495. DECLARE_GLFUNC_PTR(CompressedTexSubImage2DARB, PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC);
  496. DECLARE_GLFUNC_PTR(CompressedTexImage1DARB, PFNGLCOMPRESSEDTEXIMAGE1DARBPROC);
  497. DECLARE_GLFUNC_PTR(CompressedTexSubImage1DARB, PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC);
  498. /* If the necessary functions are missing, we can't continue */
  499. if (GetCompressedTexImageARB == NULL) {
  500. fprintf(stderr, "%s: GetCompressedTexImageARB function is missing\n",
  501. __FUNCTION__);
  502. return GL_FALSE;
  503. }
  504. switch (dimension) {
  505. case GL_TEXTURE_1D:
  506. if (CompressedTexImage1DARB == NULL || CompressedTexSubImage1DARB == NULL) {
  507. fprintf(stderr, "%s: 1D compressed texture functions are missing\n",
  508. __FUNCTION__);
  509. return GL_FALSE;
  510. };
  511. break;
  512. case GL_TEXTURE_2D:
  513. if (CompressedTexImage2DARB == NULL || CompressedTexSubImage2DARB == NULL) {
  514. fprintf(stderr, "%s: 2D compressed texture functions are missing\n",
  515. __FUNCTION__);
  516. return GL_FALSE;
  517. };
  518. break;
  519. case GL_TEXTURE_3D:
  520. if (CompressedTexImage3DARB == NULL || CompressedTexSubImage3DARB == NULL) {
  521. fprintf(stderr, "%s: 3D compressed texture functions are missing\n",
  522. __FUNCTION__);
  523. return GL_FALSE;
  524. };
  525. break;
  526. default:
  527. fprintf(stderr, "%s: unknown texture dimension 0x%04x passed.\n",
  528. __FUNCTION__, dimension);
  529. return GL_FALSE;
  530. }
  531. /* Check the compression of our base texture image. */
  532. if (!check_texture_compression("texture compression", dimension,
  533. TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_DEPTH, texture,
  534. sizeof(compressedTexture), compressedTexture)) {
  535. /* Something's wrong with texture compression. The function
  536. * above will have printed an appropriate error.
  537. */
  538. return GL_FALSE;
  539. }
  540. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  541. /* Do the same for our texture subimage */
  542. if (!check_texture_compression("subtexture compression", dimension,
  543. SUBTEXTURE_WIDTH, SUBTEXTURE_HEIGHT, SUBTEXTURE_DEPTH, subtexture,
  544. sizeof(compressedSubTexture), compressedSubTexture)) {
  545. /* Something's wrong with texture compression. The function
  546. * above will have printed an appropriate error.
  547. */
  548. return GL_FALSE;
  549. }
  550. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  551. /* Send the base compressed texture down to the hardware. */
  552. switch(dimension) {
  553. case GL_TEXTURE_3D:
  554. (*CompressedTexImage3DARB)(GL_TEXTURE_3D, 0,
  555. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  556. TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_DEPTH, 0,
  557. sizeof(compressedTexture), compressedTexture);
  558. break;
  559. case GL_TEXTURE_2D:
  560. (*CompressedTexImage2DARB)(GL_TEXTURE_2D, 0,
  561. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  562. TEXTURE_WIDTH, TEXTURE_HEIGHT, 0,
  563. sizeof(compressedTexture), compressedTexture);
  564. break;
  565. case GL_TEXTURE_1D:
  566. (*CompressedTexImage1DARB)(GL_TEXTURE_1D, 0,
  567. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  568. TEXTURE_WIDTH, 0,
  569. sizeof(compressedTexture), compressedTexture);
  570. break;
  571. }
  572. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  573. /* For grins, query it to make sure it is as expected. */
  574. glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_COMPRESSED_ARB,
  575. &queryIsCompressed);
  576. if (!queryIsCompressed) {
  577. fprintf(stderr, "%s: compressed texture did not come back as compressed\n",
  578. __FUNCTION__);
  579. return GL_FALSE;
  580. }
  581. glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_INTERNAL_FORMAT,
  582. (GLint *)&queryCompressedFormat);
  583. if (queryCompressedFormat != GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) {
  584. fprintf(stderr, "%s: got internal format 0x%04x, expected GL_COMPRESSED_RGBA_S3TC_DXT3_EXT [0x%04x]\n",
  585. __FUNCTION__, queryCompressedFormat, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
  586. return GL_FALSE;
  587. }
  588. glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB,
  589. &queryCompressedSize);
  590. if (queryCompressedSize != sizeof(compressedTexture)) {
  591. fprintf(stderr, "%s: compressed 3D texture changed size: expected %lu, actual %d\n",
  592. __FUNCTION__, (unsigned long) sizeof(compressedTexture), queryCompressedSize);
  593. return GL_FALSE;
  594. }
  595. (*GetCompressedTexImageARB)(dimension, 0, queryCompressedData);
  596. if (!compare_bytes(
  597. "exercise_CompressedTextures:doublechecking compressed texture",
  598. sizeof(compressedTexture), compressedTexture,
  599. queryCompressedSize, queryCompressedData)) {
  600. return GL_FALSE;
  601. }
  602. /* Now apply the texture subimage. The current implementation of
  603. * S3TC requires that subimages be only applied to whole blocks.
  604. */
  605. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  606. switch(dimension) {
  607. case GL_TEXTURE_3D:
  608. (*CompressedTexSubImage3DARB)(GL_TEXTURE_3D, 0,
  609. 0, 0, 0, /* offsets */
  610. SUBTEXTURE_WIDTH, SUBTEXTURE_HEIGHT, SUBTEXTURE_DEPTH,
  611. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  612. sizeof(compressedSubTexture), compressedSubTexture);
  613. break;
  614. case GL_TEXTURE_2D:
  615. (*CompressedTexSubImage2DARB)(GL_TEXTURE_2D, 0,
  616. 0, 0, /* offsets */
  617. SUBTEXTURE_WIDTH, SUBTEXTURE_HEIGHT,
  618. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  619. sizeof(compressedSubTexture), compressedSubTexture);
  620. break;
  621. case GL_TEXTURE_1D:
  622. (*CompressedTexSubImage2DARB)(GL_TEXTURE_2D, 0,
  623. 0, 0, /* offsets */
  624. SUBTEXTURE_WIDTH, SUBTEXTURE_HEIGHT,
  625. GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
  626. sizeof(compressedSubTexture), compressedSubTexture);
  627. break;
  628. }
  629. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  630. /* Query the compressed texture back now, and see that it
  631. * is as expected.
  632. */
  633. (*GetCompressedTexImageARB)(dimension, 0, queryCompressedData);
  634. if (!compare_bytes("exercise_CompressedTextures:combined texture",
  635. sizeof(compressedCombinedTexture), compressedCombinedTexture,
  636. queryCompressedSize, queryCompressedData)) {
  637. return GL_FALSE;
  638. }
  639. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  640. /* Just for the exercise, uncompress the texture and pull it out.
  641. * We don't check it because the compression is lossy, so it won't
  642. * compare exactly to the source texture; we just
  643. * want to exercise the code paths that convert it.
  644. */
  645. glGetTexImage(dimension, 0, GL_RGBA, GL_UNSIGNED_BYTE, uncompressedTexture);
  646. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  647. /* If we survived this far, we pass. */
  648. return GL_TRUE;
  649. }
  650. /**************************************************************************
  651. * Functions to assist with GL_EXT_framebuffer_object and
  652. * GL_EXT_framebuffer_blit testing.
  653. */
  654. #define FB_STATUS_NAME(x) (\
  655. x == GL_FRAMEBUFFER_COMPLETE_EXT ? "GL_FRAMEBUFFER_COMPLETE_EXT" : \
  656. x == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT" : \
  657. x == GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT" : \
  658. x == GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" : \
  659. x == GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" : \
  660. x == GL_FRAMEBUFFER_UNSUPPORTED_EXT ? "GL_FRAMEBUFFER_UNSUPPORTED_EXT" : \
  661. x == GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT" : \
  662. x == GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT" : \
  663. x == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT ? "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT" : \
  664. "unknown")
  665. static GLboolean
  666. exercise_framebuffer(void)
  667. {
  668. GLuint framebufferID = 0;
  669. GLuint renderbufferID = 0;
  670. /* Dimensions of the framebuffer and renderbuffers are arbitrary.
  671. * Since they won't be shown on-screen, we can use whatever we want.
  672. */
  673. const GLint Width = 100;
  674. const GLint Height = 100;
  675. /* Every function we use will be referenced through function pointers.
  676. * This will allow this test program to run on OpenGL implementations
  677. * that *don't* implement these extensions (though the implementation
  678. * used to compile them must have up-to-date header files).
  679. */
  680. DECLARE_GLFUNC_PTR(GenFramebuffersEXT, PFNGLGENFRAMEBUFFERSEXTPROC);
  681. DECLARE_GLFUNC_PTR(IsFramebufferEXT, PFNGLISFRAMEBUFFEREXTPROC);
  682. DECLARE_GLFUNC_PTR(DeleteFramebuffersEXT, PFNGLDELETEFRAMEBUFFERSEXTPROC);
  683. DECLARE_GLFUNC_PTR(BindFramebufferEXT, PFNGLBINDFRAMEBUFFEREXTPROC);
  684. DECLARE_GLFUNC_PTR(GenRenderbuffersEXT, PFNGLGENRENDERBUFFERSEXTPROC);
  685. DECLARE_GLFUNC_PTR(IsRenderbufferEXT, PFNGLISRENDERBUFFEREXTPROC);
  686. DECLARE_GLFUNC_PTR(DeleteRenderbuffersEXT, PFNGLDELETERENDERBUFFERSEXTPROC);
  687. DECLARE_GLFUNC_PTR(BindRenderbufferEXT, PFNGLBINDRENDERBUFFEREXTPROC);
  688. DECLARE_GLFUNC_PTR(FramebufferRenderbufferEXT, PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC);
  689. DECLARE_GLFUNC_PTR(RenderbufferStorageEXT, PFNGLRENDERBUFFERSTORAGEEXTPROC);
  690. DECLARE_GLFUNC_PTR(CheckFramebufferStatusEXT, PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC);
  691. /* The BlitFramebuffer function comes from a different extension.
  692. * It's possible for an implementation to implement all the above,
  693. * but not BlitFramebuffer; so it's okay if this one comes back
  694. * NULL, as we can still test the rest.
  695. */
  696. DECLARE_GLFUNC_PTR(BlitFramebufferEXT, PFNGLBLITFRAMEBUFFEREXTPROC);
  697. /* We cannot test unless we have all the function pointers. */
  698. if (
  699. GenFramebuffersEXT == NULL ||
  700. IsFramebufferEXT == NULL ||
  701. DeleteFramebuffersEXT == NULL ||
  702. BindFramebufferEXT == NULL ||
  703. GenRenderbuffersEXT == NULL ||
  704. IsRenderbufferEXT == NULL ||
  705. DeleteRenderbuffersEXT == NULL ||
  706. BindRenderbufferEXT == NULL ||
  707. FramebufferRenderbufferEXT == NULL ||
  708. RenderbufferStorageEXT == NULL ||
  709. CheckFramebufferStatusEXT == NULL
  710. ) {
  711. fprintf(stderr, "%s: could not locate all framebuffer functions\n",
  712. __FUNCTION__);
  713. return GL_FALSE;
  714. }
  715. /* Generate a framebuffer for us to play with. */
  716. (*GenFramebuffersEXT)(1, &framebufferID);
  717. if (framebufferID == 0) {
  718. fprintf(stderr, "%s: failed to generate a frame buffer ID.\n",
  719. __FUNCTION__);
  720. return GL_FALSE;
  721. }
  722. /* The generated name is not a framebuffer object until bound. */
  723. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, framebufferID);
  724. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  725. if (!(*IsFramebufferEXT)(framebufferID)) {
  726. fprintf(stderr, "%s: generated a frame buffer ID 0x%x that wasn't a framebuffer\n",
  727. __FUNCTION__, framebufferID);
  728. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  729. (*DeleteFramebuffersEXT)(1, &framebufferID);
  730. return GL_FALSE;
  731. }
  732. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  733. {
  734. GLint queriedFramebufferID;
  735. glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &queriedFramebufferID);
  736. if (queriedFramebufferID != framebufferID) {
  737. fprintf(stderr, "%s: bound frame buffer 0x%x, but queried 0x%x\n",
  738. __FUNCTION__, framebufferID, queriedFramebufferID);
  739. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  740. (*DeleteFramebuffersEXT)(1, &framebufferID);
  741. return GL_FALSE;
  742. }
  743. }
  744. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  745. /* Create a color buffer to attach to the frame buffer object, so
  746. * we can actually operate on it. We go through the same basic checks
  747. * with the renderbuffer that we do with the framebuffer.
  748. */
  749. (*GenRenderbuffersEXT)(1, &renderbufferID);
  750. if (renderbufferID == 0) {
  751. fprintf(stderr, "%s: could not generate a renderbuffer ID\n",
  752. __FUNCTION__);
  753. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  754. (*DeleteFramebuffersEXT)(1, &framebufferID);
  755. return GL_FALSE;
  756. }
  757. (*BindRenderbufferEXT)(GL_RENDERBUFFER_EXT, renderbufferID);
  758. if (!(*IsRenderbufferEXT)(renderbufferID)) {
  759. fprintf(stderr, "%s: generated renderbuffer 0x%x is not a renderbuffer\n",
  760. __FUNCTION__, renderbufferID);
  761. (*BindRenderbufferEXT)(GL_RENDERBUFFER_EXT, 0);
  762. (*DeleteRenderbuffersEXT)(1, &renderbufferID);
  763. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  764. (*DeleteFramebuffersEXT)(1, &framebufferID);
  765. return GL_FALSE;
  766. }
  767. {
  768. GLint queriedRenderbufferID = 0;
  769. glGetIntegerv(GL_RENDERBUFFER_BINDING_EXT, &queriedRenderbufferID);
  770. if (renderbufferID != queriedRenderbufferID) {
  771. fprintf(stderr, "%s: bound renderbuffer 0x%x, but got 0x%x\n",
  772. __FUNCTION__, renderbufferID, queriedRenderbufferID);
  773. (*BindRenderbufferEXT)(GL_RENDERBUFFER_EXT, 0);
  774. (*DeleteRenderbuffersEXT)(1, &renderbufferID);
  775. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  776. (*DeleteFramebuffersEXT)(1, &framebufferID);
  777. return GL_FALSE;
  778. }
  779. }
  780. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  781. /* Add the renderbuffer as a color attachment to the current
  782. * framebuffer (which is our generated framebuffer).
  783. */
  784. (*FramebufferRenderbufferEXT)(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
  785. GL_RENDERBUFFER_EXT, renderbufferID);
  786. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  787. /* The renderbuffer will need some dimensions and storage space. */
  788. (*RenderbufferStorageEXT)(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height);
  789. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  790. /* That should be everything we need. If we set up to draw and to
  791. * read from our color attachment, we should be "framebuffer complete",
  792. * meaning the framebuffer is ready to go.
  793. */
  794. glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
  795. glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
  796. {
  797. GLenum status = (*CheckFramebufferStatusEXT)(GL_FRAMEBUFFER_EXT);
  798. if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
  799. fprintf(stderr, "%s: framebuffer not complete; status = %s [0x%x]\n",
  800. __FUNCTION__, FB_STATUS_NAME(status), status);
  801. glReadBuffer(0);
  802. glDrawBuffer(0);
  803. (*BindRenderbufferEXT)(GL_RENDERBUFFER_EXT, 0);
  804. (*DeleteRenderbuffersEXT)(1, &renderbufferID);
  805. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  806. (*DeleteFramebuffersEXT)(1, &framebufferID);
  807. return GL_FALSE;
  808. }
  809. }
  810. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  811. /* Define the contents of the frame buffer */
  812. glClearColor(0.5, 0.5, 0.5, 0.0);
  813. glClear(GL_COLOR_BUFFER_BIT);
  814. /* If the GL_EXT_framebuffer_blit is supported, attempt a framebuffer
  815. * blit from (5,5)-(10,10) to (90,90)-(95,95). This is *not* an
  816. * error if framebuffer_blit is *not* supported (as we can still
  817. * effectively test the other functions).
  818. */
  819. if (BlitFramebufferEXT != NULL) {
  820. (*BlitFramebufferEXT)(5, 5, 10, 10, 90, 90, 95, 95,
  821. GL_COLOR_BUFFER_BIT, GL_NEAREST);
  822. }
  823. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  824. /* We could now test to see whether the framebuffer had the desired
  825. * contents. As this is just a touch test, we'll leave that for now.
  826. * Clean up and go home.
  827. */
  828. glReadBuffer(0);
  829. glDrawBuffer(0);
  830. (*BindRenderbufferEXT)(GL_RENDERBUFFER_EXT, 0);
  831. (*DeleteRenderbuffersEXT)(1, &renderbufferID);
  832. (*BindFramebufferEXT)(GL_FRAMEBUFFER_EXT, 0);
  833. (*DeleteFramebuffersEXT)(1, &framebufferID);
  834. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  835. return GL_TRUE;
  836. }
  837. /**************************************************************************
  838. * Functions to assist with GL_ARB_shader_objects testing.
  839. */
  840. static void
  841. print_info_log(const char *message, GLhandleARB object)
  842. {
  843. DECLARE_GLFUNC_PTR(GetObjectParameterivARB, PFNGLGETOBJECTPARAMETERIVARBPROC);
  844. DECLARE_GLFUNC_PTR(GetInfoLogARB, PFNGLGETINFOLOGARBPROC);
  845. int logLength, queryLength;
  846. char *log;
  847. if (GetObjectParameterivARB == NULL) {
  848. fprintf(stderr, "%s: could not get GetObjectParameterivARB address\n",
  849. message);
  850. return;
  851. }
  852. if (GetInfoLogARB == NULL) {
  853. fprintf(stderr, "%s: could not get GetInfoLogARB address\n",
  854. message);
  855. return;
  856. }
  857. (*GetObjectParameterivARB)(object, GL_OBJECT_INFO_LOG_LENGTH_ARB,
  858. &logLength);
  859. if (logLength == 0) {
  860. fprintf(stderr, "%s: info log length is 0\n", message);
  861. return;
  862. }
  863. log = malloc(logLength);
  864. if (log == NULL) {
  865. fprintf(stderr, "%s: could not malloc %d bytes for info log\n",
  866. message, logLength);
  867. }
  868. else {
  869. (*GetInfoLogARB)(object, logLength, &queryLength, log);
  870. fprintf(stderr, "%s: info log says '%s'\n",
  871. message, log);
  872. }
  873. free(log);
  874. }
  875. static GLboolean
  876. exercise_uniform_start(const char *fragmentShaderText, const char *uniformName,
  877. GLhandleARB *returnProgram, GLint *returnUniformLocation)
  878. {
  879. DECLARE_GLFUNC_PTR(CreateShaderObjectARB, PFNGLCREATESHADEROBJECTARBPROC);
  880. DECLARE_GLFUNC_PTR(ShaderSourceARB, PFNGLSHADERSOURCEARBPROC);
  881. DECLARE_GLFUNC_PTR(CompileShaderARB, PFNGLCOMPILESHADERARBPROC);
  882. DECLARE_GLFUNC_PTR(CreateProgramObjectARB, PFNGLCREATEPROGRAMOBJECTARBPROC);
  883. DECLARE_GLFUNC_PTR(AttachObjectARB, PFNGLATTACHOBJECTARBPROC);
  884. DECLARE_GLFUNC_PTR(LinkProgramARB, PFNGLLINKPROGRAMARBPROC);
  885. DECLARE_GLFUNC_PTR(UseProgramObjectARB, PFNGLUSEPROGRAMOBJECTARBPROC);
  886. DECLARE_GLFUNC_PTR(ValidateProgramARB, PFNGLVALIDATEPROGRAMARBPROC);
  887. DECLARE_GLFUNC_PTR(GetUniformLocationARB, PFNGLGETUNIFORMLOCATIONARBPROC);
  888. DECLARE_GLFUNC_PTR(DeleteObjectARB, PFNGLDELETEOBJECTARBPROC);
  889. DECLARE_GLFUNC_PTR(GetObjectParameterivARB, PFNGLGETOBJECTPARAMETERIVARBPROC);
  890. GLhandleARB fs, program;
  891. GLint uniformLocation;
  892. GLint shaderCompiled, programValidated;
  893. if (CreateShaderObjectARB == NULL ||
  894. ShaderSourceARB == NULL ||
  895. CompileShaderARB == NULL ||
  896. CreateProgramObjectARB == NULL ||
  897. AttachObjectARB == NULL ||
  898. LinkProgramARB == NULL ||
  899. UseProgramObjectARB == NULL ||
  900. ValidateProgramARB == NULL ||
  901. GetUniformLocationARB == NULL ||
  902. DeleteObjectARB == NULL ||
  903. GetObjectParameterivARB == NULL ||
  904. 0) {
  905. return GL_FALSE;
  906. }
  907. /* Create the trivial fragment shader and program. For safety
  908. * we'll check to make sure they compile and link correctly.
  909. */
  910. fs = (*CreateShaderObjectARB)(GL_FRAGMENT_SHADER_ARB);
  911. (*ShaderSourceARB)(fs, 1, &fragmentShaderText, NULL);
  912. (*CompileShaderARB)(fs);
  913. (*GetObjectParameterivARB)(fs, GL_OBJECT_COMPILE_STATUS_ARB,
  914. &shaderCompiled);
  915. if (!shaderCompiled) {
  916. print_info_log("shader did not compile", fs);
  917. (*DeleteObjectARB)(fs);
  918. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  919. return GL_FALSE;
  920. }
  921. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  922. program = (*CreateProgramObjectARB)();
  923. (*AttachObjectARB)(program, fs);
  924. (*LinkProgramARB)(program);
  925. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  926. /* Make sure we're going to run successfully */
  927. (*ValidateProgramARB)(program);
  928. (*GetObjectParameterivARB)(program, GL_OBJECT_VALIDATE_STATUS_ARB,
  929. &programValidated);
  930. if (!programValidated) {;
  931. print_info_log("program did not validate", program);
  932. (*DeleteObjectARB)(program);
  933. (*DeleteObjectARB)(fs);
  934. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  935. return GL_FALSE;
  936. }
  937. /* Put the program in place. We're not allowed to assign to uniform
  938. * variables used by the program until the program is put into use.
  939. */
  940. (*UseProgramObjectARB)(program);
  941. /* Once the shader is in place, we're free to delete it; this
  942. * won't affect the copy that's part of the program.
  943. */
  944. (*DeleteObjectARB)(fs);
  945. /* Find the location index of the uniform variable we declared;
  946. * the caller will ned that to set the value.
  947. */
  948. uniformLocation = (*GetUniformLocationARB)(program, uniformName);
  949. if (uniformLocation == -1) {
  950. fprintf(stderr, "%s: could not determine uniform location\n",
  951. __FUNCTION__);
  952. (*DeleteObjectARB)(program);
  953. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  954. return GL_FALSE;
  955. }
  956. /* All done with what we're supposed to do - return the program
  957. * handle and the uniform location to the caller.
  958. */
  959. *returnProgram = program;
  960. *returnUniformLocation = uniformLocation;
  961. return GL_TRUE;
  962. }
  963. static void
  964. exercise_uniform_end(GLhandleARB program)
  965. {
  966. DECLARE_GLFUNC_PTR(UseProgramObjectARB, PFNGLUSEPROGRAMOBJECTARBPROC);
  967. DECLARE_GLFUNC_PTR(DeleteObjectARB, PFNGLDELETEOBJECTARBPROC);
  968. if (UseProgramObjectARB == NULL || DeleteObjectARB == NULL) {
  969. return;
  970. }
  971. /* Turn off our program by setting the special value 0, and
  972. * then delete the program object.
  973. */
  974. (*UseProgramObjectARB)(0);
  975. (*DeleteObjectARB)(program);
  976. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  977. }
  978. /**************************************************************************
  979. * Exercises for fences
  980. */
  981. static GLboolean
  982. exercise_fences(void)
  983. {
  984. DECLARE_GLFUNC_PTR(DeleteFencesNV, PFNGLDELETEFENCESNVPROC);
  985. DECLARE_GLFUNC_PTR(FinishFenceNV, PFNGLFINISHFENCENVPROC);
  986. DECLARE_GLFUNC_PTR(GenFencesNV, PFNGLGENFENCESNVPROC);
  987. DECLARE_GLFUNC_PTR(GetFenceivNV, PFNGLGETFENCEIVNVPROC);
  988. DECLARE_GLFUNC_PTR(IsFenceNV, PFNGLISFENCENVPROC);
  989. DECLARE_GLFUNC_PTR(SetFenceNV, PFNGLSETFENCENVPROC);
  990. DECLARE_GLFUNC_PTR(TestFenceNV, PFNGLTESTFENCENVPROC);
  991. GLuint fence;
  992. GLint fenceStatus, fenceCondition;
  993. int count;
  994. /* Make sure we have all the function pointers we need. */
  995. if (GenFencesNV == NULL ||
  996. SetFenceNV == NULL ||
  997. IsFenceNV == NULL ||
  998. GetFenceivNV == NULL ||
  999. TestFenceNV == NULL ||
  1000. FinishFenceNV == NULL ||
  1001. DeleteFencesNV == NULL) {
  1002. fprintf(stderr, "%s: don't have all the fence functions\n",
  1003. __FUNCTION__);
  1004. return GL_FALSE;
  1005. }
  1006. /* Create and set a simple fence. */
  1007. (*GenFencesNV)(1, &fence);
  1008. (*SetFenceNV)(fence, GL_ALL_COMPLETED_NV);
  1009. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1010. /* Make sure it reads as a fence. */
  1011. if (!(*IsFenceNV)(fence)) {
  1012. fprintf(stderr, "%s: set fence is not a fence\n", __FUNCTION__);
  1013. (*DeleteFencesNV)(1, &fence);
  1014. return GL_FALSE;
  1015. }
  1016. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1017. /* Try to read back its current status and condition. */
  1018. (*GetFenceivNV)(fence, GL_FENCE_CONDITION_NV, &fenceCondition);
  1019. if (fenceCondition != GL_ALL_COMPLETED_NV) {
  1020. fprintf(stderr, "%s: expected fence condition 0x%x, got 0x%x\n",
  1021. __FUNCTION__, GL_ALL_COMPLETED_NV, fenceCondition);
  1022. (*DeleteFencesNV)(1, &fence);
  1023. return GL_FALSE;
  1024. }
  1025. (*GetFenceivNV)(fence, GL_FENCE_STATUS_NV, &fenceStatus);
  1026. if (fenceStatus != GL_TRUE && fenceStatus != GL_FALSE) {
  1027. fprintf(stderr,"%s: fence status should be GL_TRUE or GL_FALSE, got 0x%x\n",
  1028. __FUNCTION__, fenceStatus);
  1029. (*DeleteFencesNV)(1, &fence);
  1030. return GL_FALSE;
  1031. }
  1032. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1033. /* Set the fence again, query its status, and wait for it to finish
  1034. * two different ways: once by looping on TestFence(), and a
  1035. * second time by a simple call to FinishFence();
  1036. */
  1037. (*SetFenceNV)(fence, GL_ALL_COMPLETED_NV);
  1038. glFlush();
  1039. count = 1;
  1040. while (!(*TestFenceNV)(fence)) {
  1041. count++;
  1042. if (count == 0) {
  1043. break;
  1044. }
  1045. }
  1046. if (count == 0) {
  1047. fprintf(stderr, "%s: fence never returned true\n", __FUNCTION__);
  1048. (*DeleteFencesNV)(1, &fence);
  1049. return GL_FALSE;
  1050. }
  1051. (*SetFenceNV)(fence, GL_ALL_COMPLETED_NV);
  1052. (*FinishFenceNV)(fence);
  1053. if ((*TestFenceNV)(fence) != GL_TRUE) {
  1054. fprintf(stderr, "%s: finished fence does not have status GL_TRUE\n",
  1055. __FUNCTION__);
  1056. (*DeleteFencesNV)(1, &fence);
  1057. return GL_FALSE;
  1058. }
  1059. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1060. /* All done. Delete the fence and return. */
  1061. (*DeleteFencesNV)(1, &fence);
  1062. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1063. return GL_TRUE;
  1064. }
  1065. /**************************************************************************
  1066. * Exercises for buffer objects
  1067. */
  1068. enum Map_Buffer_Usage{ Use_Map_Buffer, Use_Map_Buffer_Range};
  1069. static GLboolean
  1070. exercise_buffer_objects(enum Map_Buffer_Usage usage)
  1071. {
  1072. #define BUFFER_DATA_SIZE 1024
  1073. GLuint bufferID;
  1074. GLint bufferMapped;
  1075. static GLubyte data[BUFFER_DATA_SIZE] = {0};
  1076. float *dataPtr = NULL;
  1077. const char *extensions = (const char *) glGetString(GL_EXTENSIONS);
  1078. /* Get the function pointers we need. These are from
  1079. * GL_ARB_vertex_buffer_object and are required in all
  1080. * cases.
  1081. */
  1082. DECLARE_GLFUNC_PTR(GenBuffersARB, PFNGLGENBUFFERSARBPROC);
  1083. DECLARE_GLFUNC_PTR(BindBufferARB, PFNGLBINDBUFFERARBPROC);
  1084. DECLARE_GLFUNC_PTR(BufferDataARB, PFNGLBUFFERDATAARBPROC);
  1085. DECLARE_GLFUNC_PTR(MapBufferARB, PFNGLMAPBUFFERARBPROC);
  1086. DECLARE_GLFUNC_PTR(UnmapBufferARB, PFNGLUNMAPBUFFERARBPROC);
  1087. DECLARE_GLFUNC_PTR(DeleteBuffersARB, PFNGLDELETEBUFFERSARBPROC);
  1088. DECLARE_GLFUNC_PTR(GetBufferParameterivARB, PFNGLGETBUFFERPARAMETERIVARBPROC);
  1089. /* These are from GL_ARB_map_buffer_range, and are optional
  1090. * unless we're given Use_Map_Buffer_Range. Note that they do *not*
  1091. * have the standard "ARB" suffixes; this is because the extension
  1092. * was introduced *after* a superset was standardized in OpenGL 3.0.
  1093. * (The extension really only exists to allow the functionality on
  1094. * devices that cannot implement a full OpenGL 3.0 driver.)
  1095. */
  1096. DECLARE_GLFUNC_PTR(FlushMappedBufferRange, PFNGLFLUSHMAPPEDBUFFERRANGEPROC);
  1097. DECLARE_GLFUNC_PTR(MapBufferRange, PFNGLMAPBUFFERRANGEPROC);
  1098. /* This is from APPLE_flush_buffer_range, and is optional even if
  1099. * we're given Use_Map_Buffer_Range. Test it before using it.
  1100. */
  1101. DECLARE_GLFUNC_PTR(BufferParameteriAPPLE, PFNGLBUFFERPARAMETERIAPPLEPROC);
  1102. if (!strstr("GL_APPLE_flush_buffer_range", extensions)) {
  1103. BufferParameteriAPPLE = NULL;
  1104. }
  1105. /* Make sure we have all the function pointers we need. */
  1106. if (GenBuffersARB == NULL ||
  1107. BindBufferARB == NULL ||
  1108. BufferDataARB == NULL ||
  1109. MapBufferARB == NULL ||
  1110. UnmapBufferARB == NULL ||
  1111. DeleteBuffersARB == NULL ||
  1112. GetBufferParameterivARB == NULL) {
  1113. fprintf(stderr, "%s: missing basic MapBuffer functions\n", __FUNCTION__);
  1114. return GL_FALSE;
  1115. }
  1116. if (usage == Use_Map_Buffer_Range) {
  1117. if (FlushMappedBufferRange == NULL || MapBufferRange == NULL) {
  1118. fprintf(stderr, "%s: missing MapBufferRange functions\n", __FUNCTION__);
  1119. return GL_FALSE;
  1120. }
  1121. }
  1122. /* Create and define a buffer */
  1123. (*GenBuffersARB)(1, &bufferID);
  1124. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, bufferID);
  1125. (*BufferDataARB)(GL_ARRAY_BUFFER_ARB, BUFFER_DATA_SIZE, data,
  1126. GL_DYNAMIC_DRAW_ARB);
  1127. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1128. /* If we're using MapBufferRange, and if the BufferParameteriAPPLE
  1129. * function is present, use it before mapping. This particular
  1130. * use is a no-op, intended just to exercise the entry point.
  1131. */
  1132. if (usage == Use_Map_Buffer_Range && BufferParameteriAPPLE != NULL) {
  1133. (*BufferParameteriAPPLE)(GL_ARRAY_BUFFER_ARB,
  1134. GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE);
  1135. }
  1136. /* Map it, and make sure it's mapped. */
  1137. switch(usage) {
  1138. case Use_Map_Buffer:
  1139. dataPtr = (float *) (*MapBufferARB)(
  1140. GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
  1141. break;
  1142. case Use_Map_Buffer_Range:
  1143. dataPtr = (float *)(*MapBufferRange)(GL_ARRAY_BUFFER_ARB,
  1144. 4, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
  1145. break;
  1146. }
  1147. if (dataPtr == NULL) {
  1148. fprintf(stderr, "%s: %s returned NULL\n", __FUNCTION__,
  1149. usage == Use_Map_Buffer ? "MapBuffer" : "MapBufferRange");
  1150. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1151. (*DeleteBuffersARB)(1, &bufferID);
  1152. return GL_FALSE;
  1153. }
  1154. (*GetBufferParameterivARB)(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB,
  1155. &bufferMapped);
  1156. if (!bufferMapped) {
  1157. fprintf(stderr, "%s: buffer should be mapped but isn't\n", __FUNCTION__);
  1158. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1159. (*DeleteBuffersARB)(1, &bufferID);
  1160. return GL_FALSE;
  1161. }
  1162. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1163. /* Write something to it, just to make sure we don't segfault. */
  1164. *dataPtr = 1.5;
  1165. /* Unmap to show we're finished with the buffer. Note that if we're
  1166. * using MapBufferRange, we first have to flush the range we modified.
  1167. */
  1168. if (usage == Use_Map_Buffer_Range) {
  1169. (*FlushMappedBufferRange)(GL_ARRAY_BUFFER_ARB, 0, 16);
  1170. }
  1171. if (!(*UnmapBufferARB)(GL_ARRAY_BUFFER_ARB)) {
  1172. fprintf(stderr, "%s: UnmapBuffer failed\n", __FUNCTION__);
  1173. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1174. (*DeleteBuffersARB)(1, &bufferID);
  1175. return GL_FALSE;
  1176. }
  1177. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1178. /* All done. */
  1179. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1180. (*DeleteBuffersARB)(1, &bufferID);
  1181. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1182. return GL_TRUE;
  1183. #undef BUFFER_DATA_SIZE
  1184. }
  1185. /**************************************************************************
  1186. * Exercises for occlusion query
  1187. */
  1188. static GLboolean
  1189. exercise_occlusion_query(void)
  1190. {
  1191. GLuint queryObject;
  1192. GLint queryReady;
  1193. GLuint querySampleCount;
  1194. GLint queryCurrent;
  1195. GLint queryCounterBits;
  1196. /* Get the function pointers we need. These are from
  1197. * GL_ARB_vertex_buffer_object and are required in all
  1198. * cases.
  1199. */
  1200. DECLARE_GLFUNC_PTR(GenQueriesARB, PFNGLGENQUERIESARBPROC);
  1201. DECLARE_GLFUNC_PTR(BeginQueryARB, PFNGLBEGINQUERYARBPROC);
  1202. DECLARE_GLFUNC_PTR(GetQueryivARB, PFNGLGETQUERYIVARBPROC);
  1203. DECLARE_GLFUNC_PTR(EndQueryARB, PFNGLENDQUERYARBPROC);
  1204. DECLARE_GLFUNC_PTR(IsQueryARB, PFNGLISQUERYARBPROC);
  1205. DECLARE_GLFUNC_PTR(GetQueryObjectivARB, PFNGLGETQUERYOBJECTIVARBPROC);
  1206. DECLARE_GLFUNC_PTR(GetQueryObjectuivARB, PFNGLGETQUERYOBJECTUIVARBPROC);
  1207. DECLARE_GLFUNC_PTR(DeleteQueriesARB, PFNGLDELETEQUERIESARBPROC);
  1208. /* Make sure we have all the function pointers we need. */
  1209. if (GenQueriesARB == NULL ||
  1210. BeginQueryARB == NULL ||
  1211. GetQueryivARB == NULL ||
  1212. EndQueryARB == NULL ||
  1213. IsQueryARB == NULL ||
  1214. GetQueryObjectivARB == NULL ||
  1215. GetQueryObjectuivARB == NULL ||
  1216. DeleteQueriesARB == NULL) {
  1217. fprintf(stderr, "%s: don't have all the Query functions\n", __FUNCTION__);
  1218. return GL_FALSE;
  1219. }
  1220. /* Create a query object, and start a query. */
  1221. (*GenQueriesARB)(1, &queryObject);
  1222. (*BeginQueryARB)(GL_SAMPLES_PASSED_ARB, queryObject);
  1223. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1224. /* While we're in the query, check the functions that are supposed
  1225. * to return which query we're in and how many bits of resolution
  1226. * we get.
  1227. */
  1228. (*GetQueryivARB)(GL_SAMPLES_PASSED_ARB, GL_CURRENT_QUERY_ARB, &queryCurrent);
  1229. if (queryCurrent != queryObject) {
  1230. fprintf(stderr, "%s: current query 0x%x != set query 0x%x\n",
  1231. __FUNCTION__, queryCurrent, queryObject);
  1232. (*EndQueryARB)(GL_SAMPLES_PASSED_ARB);
  1233. (*DeleteQueriesARB)(1, &queryObject);
  1234. return GL_FALSE;
  1235. }
  1236. (*GetQueryivARB)(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
  1237. &queryCounterBits);
  1238. if (queryCounterBits < 1) {
  1239. fprintf(stderr, "%s: query counter bits is too small (%d)\n",
  1240. __FUNCTION__, queryCounterBits);
  1241. (*EndQueryARB)(GL_SAMPLES_PASSED_ARB);
  1242. (*DeleteQueriesARB)(1, &queryObject);
  1243. return GL_FALSE;
  1244. }
  1245. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1246. /* Finish up the query. Since we didn't draw anything, the result
  1247. * should be 0 passed samples.
  1248. */
  1249. (*EndQueryARB)(GL_SAMPLES_PASSED_ARB);
  1250. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1251. /* Routine existence test */
  1252. if (!(*IsQueryARB)(queryObject)) {
  1253. fprintf(stderr, "%s: query object 0x%x fails existence test\n",
  1254. __FUNCTION__, queryObject);
  1255. (*DeleteQueriesARB)(1, &queryObject);
  1256. return GL_FALSE;
  1257. }
  1258. /* Loop until the query is ready, then get back the result. We use
  1259. * the signed query for the boolean value of whether the result is
  1260. * available, but the unsigned query to actually pull the result;
  1261. * this is just to test both entrypoints, but in a real query you may
  1262. * need the extra bit of resolution.
  1263. */
  1264. queryReady = GL_FALSE;
  1265. do {
  1266. (*GetQueryObjectivARB)(queryObject, GL_QUERY_RESULT_AVAILABLE_ARB,
  1267. &queryReady);
  1268. } while (!queryReady);
  1269. (*GetQueryObjectuivARB)(queryObject, GL_QUERY_RESULT_ARB, &querySampleCount);
  1270. (*DeleteQueriesARB)(1, &queryObject);
  1271. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1272. /* If sample count isn't 0, something's funny. */
  1273. if (querySampleCount > 0) {
  1274. fprintf(stderr, "%s: expected query result of 0, got %ud\n",
  1275. __FUNCTION__, querySampleCount);
  1276. return GL_FALSE;
  1277. }
  1278. /* Here, all is well. */
  1279. return GL_TRUE;
  1280. }
  1281. /**************************************************************************
  1282. * The following functions are used to check that the named OpenGL function
  1283. * actually does what it's supposed to do.
  1284. * The naming of these functions is significant. The getprocaddress.py script
  1285. * scans this file and extracts these function names.
  1286. */
  1287. static GLboolean
  1288. test_WeightPointerARB(generic_func func)
  1289. {
  1290. /* Assume we have at least 2 vertex units (or this extension makes
  1291. * no sense), and establish a set of 2-element vector weights.
  1292. * We use floats that can be represented exactly in binary
  1293. * floating point formats so we can compare correctly later.
  1294. * We also make sure the 0th entry matches the default weights,
  1295. * so we can restore the default easily.
  1296. */
  1297. #define USE_VERTEX_UNITS 2
  1298. #define USE_WEIGHT_INDEX 3
  1299. static GLfloat weights[] = {
  1300. 1.0, 0.0,
  1301. 0.875, 0.125,
  1302. 0.75, 0.25,
  1303. 0.625, 0.375,
  1304. 0.5, 0.5,
  1305. 0.375, 0.625,
  1306. 0.25, 0.75,
  1307. 0.125, 0.875,
  1308. 0.0, 1.0,
  1309. };
  1310. GLint numVertexUnits;
  1311. GLfloat *currentWeights;
  1312. int i;
  1313. int errorCount = 0;
  1314. PFNGLWEIGHTPOINTERARBPROC WeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC) func;
  1315. /* Make sure we have at least two vertex units */
  1316. glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &numVertexUnits);
  1317. if (numVertexUnits < USE_VERTEX_UNITS) {
  1318. fprintf(stderr, "%s: need %d vertex units, got %d\n",
  1319. __FUNCTION__, USE_VERTEX_UNITS, numVertexUnits);
  1320. return GL_FALSE;
  1321. }
  1322. /* Make sure we allocate enough room to query all the current weights */
  1323. currentWeights = (GLfloat *)malloc(numVertexUnits * sizeof(GLfloat));
  1324. if (currentWeights == NULL) {
  1325. fprintf(stderr, "%s: couldn't allocate room for %d floats\n",
  1326. __FUNCTION__, numVertexUnits);
  1327. return GL_FALSE;
  1328. }
  1329. /* Set up the pointer, enable the state, and try to send down a
  1330. * weight vector (we'll arbitrarily send index 2).
  1331. */
  1332. (*WeightPointerARB)(USE_VERTEX_UNITS, GL_FLOAT, 0, weights);
  1333. glEnableClientState(GL_WEIGHT_ARRAY_ARB);
  1334. glArrayElement(USE_WEIGHT_INDEX);
  1335. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1336. /* Verify that it changed the current state. */
  1337. glGetFloatv(GL_CURRENT_WEIGHT_ARB, currentWeights);
  1338. for (i = 0; i < numVertexUnits; i++) {
  1339. if (i < USE_VERTEX_UNITS) {
  1340. /* This is one of the units we explicitly set. */
  1341. if (currentWeights[i] != weights[USE_VERTEX_UNITS*USE_WEIGHT_INDEX + i]) {
  1342. fprintf(stderr, "%s: current weight at index %d is %f, should be %f\n",
  1343. __FUNCTION__, i, currentWeights[i],
  1344. weights[USE_VERTEX_UNITS*USE_WEIGHT_INDEX + i]);
  1345. errorCount++;
  1346. }
  1347. }
  1348. else {
  1349. /* All other weights should be 0. */
  1350. if (currentWeights[i] != 0.0) {
  1351. fprintf(stderr, "%s: current weight at index %d is %f, should be %f\n",
  1352. __FUNCTION__, i, 0.0,
  1353. weights[USE_VERTEX_UNITS*USE_WEIGHT_INDEX + i]);
  1354. errorCount++;
  1355. }
  1356. }
  1357. }
  1358. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1359. /* Restore the old state. We know the default set of weights is in
  1360. * index 0.
  1361. */
  1362. glArrayElement(0);
  1363. glDisableClientState(GL_WEIGHT_ARRAY_ARB);
  1364. (*WeightPointerARB)(0, GL_FLOAT, 0, NULL);
  1365. free(currentWeights);
  1366. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1367. /* We're fine if we didn't get any mismatches. */
  1368. if (errorCount == 0) {
  1369. return GL_TRUE;
  1370. }
  1371. else {
  1372. return GL_FALSE;
  1373. }
  1374. }
  1375. /* Wrappers on the exercise_occlusion_query function */
  1376. static GLboolean
  1377. test_GenQueriesARB(generic_func func)
  1378. {
  1379. (void) func;
  1380. return exercise_occlusion_query();
  1381. }
  1382. static GLboolean
  1383. test_BeginQueryARB(generic_func func)
  1384. {
  1385. (void) func;
  1386. return exercise_occlusion_query();
  1387. }
  1388. static GLboolean
  1389. test_GetQueryivARB(generic_func func)
  1390. {
  1391. (void) func;
  1392. return exercise_occlusion_query();
  1393. }
  1394. static GLboolean
  1395. test_EndQueryARB(generic_func func)
  1396. {
  1397. (void) func;
  1398. return exercise_occlusion_query();
  1399. }
  1400. static GLboolean
  1401. test_IsQueryARB(generic_func func)
  1402. {
  1403. (void) func;
  1404. return exercise_occlusion_query();
  1405. }
  1406. static GLboolean
  1407. test_GetQueryObjectivARB(generic_func func)
  1408. {
  1409. (void) func;
  1410. return exercise_occlusion_query();
  1411. }
  1412. static GLboolean
  1413. test_GetQueryObjectuivARB(generic_func func)
  1414. {
  1415. (void) func;
  1416. return exercise_occlusion_query();
  1417. }
  1418. static GLboolean
  1419. test_DeleteQueriesARB(generic_func func)
  1420. {
  1421. (void) func;
  1422. return exercise_occlusion_query();
  1423. }
  1424. /* Wrappers on the exercise_buffer_objects() function */
  1425. static GLboolean
  1426. test_GenBuffersARB(generic_func func)
  1427. {
  1428. (void) func;
  1429. return exercise_buffer_objects(Use_Map_Buffer);
  1430. }
  1431. static GLboolean
  1432. test_BindBufferARB(generic_func func)
  1433. {
  1434. (void) func;
  1435. return exercise_buffer_objects(Use_Map_Buffer);
  1436. }
  1437. static GLboolean
  1438. test_BufferDataARB(generic_func func)
  1439. {
  1440. (void) func;
  1441. return exercise_buffer_objects(Use_Map_Buffer);
  1442. }
  1443. static GLboolean
  1444. test_MapBufferARB(generic_func func)
  1445. {
  1446. (void) func;
  1447. return exercise_buffer_objects(Use_Map_Buffer);
  1448. }
  1449. static GLboolean
  1450. test_UnmapBufferARB(generic_func func)
  1451. {
  1452. (void) func;
  1453. return exercise_buffer_objects(Use_Map_Buffer);
  1454. }
  1455. static GLboolean
  1456. test_DeleteBuffersARB(generic_func func)
  1457. {
  1458. (void) func;
  1459. return exercise_buffer_objects(Use_Map_Buffer);
  1460. }
  1461. static GLboolean
  1462. test_GetBufferParameterivARB(generic_func func)
  1463. {
  1464. (void) func;
  1465. return exercise_buffer_objects(Use_Map_Buffer);
  1466. }
  1467. static GLboolean
  1468. test_FlushMappedBufferRange(generic_func func)
  1469. {
  1470. (void) func;
  1471. return exercise_buffer_objects(Use_Map_Buffer_Range);
  1472. }
  1473. static GLboolean
  1474. test_MapBufferRange(generic_func func)
  1475. {
  1476. (void) func;
  1477. return exercise_buffer_objects(Use_Map_Buffer_Range);
  1478. }
  1479. static GLboolean
  1480. test_BufferParameteriAPPLE(generic_func func)
  1481. {
  1482. (void) func;
  1483. return exercise_buffer_objects(Use_Map_Buffer_Range);
  1484. }
  1485. /* Wrappers on the exercise_framebuffer() function */
  1486. static GLboolean
  1487. test_BindFramebufferEXT(generic_func func)
  1488. {
  1489. (void) func;
  1490. return exercise_framebuffer();
  1491. }
  1492. static GLboolean
  1493. test_BindRenderbufferEXT(generic_func func)
  1494. {
  1495. (void) func;
  1496. return exercise_framebuffer();
  1497. }
  1498. static GLboolean
  1499. test_CheckFramebufferStatusEXT(generic_func func)
  1500. {
  1501. (void) func;
  1502. return exercise_framebuffer();
  1503. }
  1504. static GLboolean
  1505. test_DeleteFramebuffersEXT(generic_func func)
  1506. {
  1507. (void) func;
  1508. return exercise_framebuffer();
  1509. }
  1510. static GLboolean
  1511. test_DeleteRenderbuffersEXT(generic_func func)
  1512. {
  1513. (void) func;
  1514. return exercise_framebuffer();
  1515. }
  1516. static GLboolean
  1517. test_FramebufferRenderbufferEXT(generic_func func)
  1518. {
  1519. (void) func;
  1520. return exercise_framebuffer();
  1521. }
  1522. static GLboolean
  1523. test_GenFramebuffersEXT(generic_func func)
  1524. {
  1525. (void) func;
  1526. return exercise_framebuffer();
  1527. }
  1528. static GLboolean
  1529. test_GenRenderbuffersEXT(generic_func func)
  1530. {
  1531. (void) func;
  1532. return exercise_framebuffer();
  1533. }
  1534. static GLboolean
  1535. test_IsFramebufferEXT(generic_func func)
  1536. {
  1537. (void) func;
  1538. return exercise_framebuffer();
  1539. }
  1540. static GLboolean
  1541. test_IsRenderbufferEXT(generic_func func)
  1542. {
  1543. (void) func;
  1544. return exercise_framebuffer();
  1545. }
  1546. static GLboolean
  1547. test_RenderbufferStorageEXT(generic_func func)
  1548. {
  1549. (void) func;
  1550. return exercise_framebuffer();
  1551. }
  1552. static GLboolean
  1553. test_BlitFramebufferEXT(generic_func func)
  1554. {
  1555. (void) func;
  1556. return exercise_framebuffer();
  1557. }
  1558. /* These are wrappers on the exercise_CompressedTextures function.
  1559. * Unfortunately, we cannot test the 1D counterparts, because the
  1560. * texture compressions available all support 2D and higher only.
  1561. */
  1562. static GLboolean
  1563. test_CompressedTexImage2DARB(generic_func func)
  1564. {
  1565. (void) func;
  1566. return exercise_CompressedTextures(GL_TEXTURE_2D);
  1567. }
  1568. static GLboolean
  1569. test_CompressedTexSubImage2DARB(generic_func func)
  1570. {
  1571. (void) func;
  1572. return exercise_CompressedTextures(GL_TEXTURE_2D);
  1573. }
  1574. static GLboolean
  1575. test_CompressedTexImage3DARB(generic_func func)
  1576. {
  1577. (void) func;
  1578. return exercise_CompressedTextures(GL_TEXTURE_3D);
  1579. }
  1580. static GLboolean
  1581. test_CompressedTexSubImage3DARB(generic_func func)
  1582. {
  1583. (void) func;
  1584. return exercise_CompressedTextures(GL_TEXTURE_3D);
  1585. }
  1586. static GLboolean
  1587. test_GetCompressedTexImageARB(generic_func func)
  1588. {
  1589. (void) func;
  1590. return exercise_CompressedTextures(GL_TEXTURE_3D);
  1591. }
  1592. /* Wrappers on exercise_fences(). */
  1593. static GLboolean
  1594. test_DeleteFencesNV(generic_func func)
  1595. {
  1596. (void) func;
  1597. return exercise_fences();
  1598. }
  1599. static GLboolean
  1600. test_GenFencesNV(generic_func func)
  1601. {
  1602. (void) func;
  1603. return exercise_fences();
  1604. }
  1605. static GLboolean
  1606. test_SetFenceNV(generic_func func)
  1607. {
  1608. (void) func;
  1609. return exercise_fences();
  1610. }
  1611. static GLboolean
  1612. test_TestFenceNV(generic_func func)
  1613. {
  1614. (void) func;
  1615. return exercise_fences();
  1616. }
  1617. static GLboolean
  1618. test_FinishFenceNV(generic_func func)
  1619. {
  1620. (void) func;
  1621. return exercise_fences();
  1622. }
  1623. static GLboolean
  1624. test_GetFenceivNV(generic_func func)
  1625. {
  1626. (void) func;
  1627. return exercise_fences();
  1628. }
  1629. static GLboolean
  1630. test_IsFenceNV(generic_func func)
  1631. {
  1632. (void) func;
  1633. return exercise_fences();
  1634. }
  1635. /* A bunch of glUniform*() tests */
  1636. static GLboolean
  1637. test_Uniform1iv(generic_func func)
  1638. {
  1639. PFNGLUNIFORM1IVARBPROC Uniform1ivARB = (PFNGLUNIFORM1IVARBPROC) func;
  1640. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1641. /* This is a trivial fragment shader that sets the color of the
  1642. * fragment to the uniform value passed in.
  1643. */
  1644. static const char *fragmentShaderText =
  1645. "uniform int uniformColor;"
  1646. "void main() {gl_FragColor.r = uniformColor;}";
  1647. static const char *uniformName = "uniformColor";
  1648. GLhandleARB program;
  1649. GLint uniformLocation;
  1650. const GLint uniform[1] = {1};
  1651. GLint queriedUniform[1];
  1652. if (GetUniformivARB == NULL) {
  1653. return GL_FALSE;
  1654. }
  1655. /* Call a helper function to compile up the shader and give
  1656. * us back the validated program and uniform location.
  1657. * If it fails, something's wrong and we can't continue.
  1658. */
  1659. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1660. &program, &uniformLocation)) {
  1661. return GL_FALSE;
  1662. }
  1663. /* Set the value of the program uniform. Note that you must
  1664. * use a compatible type. Our uniform above is an integer
  1665. * so we must set it using integer versions
  1666. * of the Uniform* functions. The "1" means we're setting
  1667. * one vector's worth of information.
  1668. */
  1669. (*Uniform1ivARB)(uniformLocation, 1, uniform);
  1670. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1671. /* Query it back */
  1672. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1673. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1674. /* Clean up before we check to see whether it came back unscathed */
  1675. exercise_uniform_end(program);
  1676. /* Now check to see whether the uniform came back as expected. This
  1677. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1678. */
  1679. return compare_ints(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1680. }
  1681. static GLboolean
  1682. test_Uniform1i(generic_func func)
  1683. {
  1684. PFNGLUNIFORM1IARBPROC Uniform1iARB = (PFNGLUNIFORM1IARBPROC) func;
  1685. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1686. /* This is a trivial fragment shader that sets the color of the
  1687. * fragment to the uniform value passed in.
  1688. */
  1689. static const char *fragmentShaderText =
  1690. "uniform int uniformColor;"
  1691. "void main() {gl_FragColor.r = uniformColor;}";
  1692. static const char *uniformName = "uniformColor";
  1693. GLhandleARB program;
  1694. GLint uniformLocation;
  1695. const GLint uniform[1] = {1};
  1696. GLint queriedUniform[4];
  1697. if (GetUniformivARB == NULL) {
  1698. return GL_FALSE;
  1699. }
  1700. /* Call a helper function to compile up the shader and give
  1701. * us back the validated program and uniform location.
  1702. * If it fails, something's wrong and we can't continue.
  1703. */
  1704. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1705. &program, &uniformLocation)) {
  1706. return GL_FALSE;
  1707. }
  1708. /* Set the value of the program uniform. Note that you must
  1709. * use a compatible type. Our uniform above is an integer
  1710. * so we must set it using integer versions
  1711. * of the Uniform* functions.
  1712. */
  1713. (*Uniform1iARB)(uniformLocation, uniform[0]);
  1714. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1715. /* Query it back */
  1716. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1717. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1718. /* Clean up before we check to see whether it came back unscathed */
  1719. exercise_uniform_end(program);
  1720. /* Now check to see whether the uniform came back as expected. This
  1721. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1722. */
  1723. return compare_ints(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1724. }
  1725. static GLboolean
  1726. test_Uniform1fv(generic_func func)
  1727. {
  1728. PFNGLUNIFORM1FVARBPROC Uniform1fvARB = (PFNGLUNIFORM1FVARBPROC) func;
  1729. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1730. /* This is a trivial fragment shader that sets the color of the
  1731. * fragment to the uniform value passed in.
  1732. */
  1733. static const char *fragmentShaderText =
  1734. "uniform float uniformColor;"
  1735. "void main() {gl_FragColor.r = uniformColor;}";
  1736. static const char *uniformName = "uniformColor";
  1737. GLhandleARB program;
  1738. GLint uniformLocation;
  1739. const GLfloat uniform[1] = {1.1};
  1740. GLfloat queriedUniform[1];
  1741. if (GetUniformfvARB == NULL) {
  1742. return GL_FALSE;
  1743. }
  1744. /* Call a helper function to compile up the shader and give
  1745. * us back the validated program and uniform location.
  1746. * If it fails, something's wrong and we can't continue.
  1747. */
  1748. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1749. &program, &uniformLocation)) {
  1750. return GL_FALSE;
  1751. }
  1752. /* Set the value of the program uniform. Note that you must
  1753. * use a compatible type. Our uniform above is a float
  1754. * so we must set it using float versions
  1755. * of the Uniform* functions. The "1" means we're setting
  1756. * one vector's worth of information.
  1757. */
  1758. (*Uniform1fvARB)(uniformLocation, 1, uniform);
  1759. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1760. /* Query it back */
  1761. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1762. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1763. /* Clean up before we check to see whether it came back unscathed */
  1764. exercise_uniform_end(program);
  1765. /* Now check to see whether the uniform came back as expected. This
  1766. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1767. */
  1768. return compare_floats(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1769. }
  1770. static GLboolean
  1771. test_Uniform1f(generic_func func)
  1772. {
  1773. PFNGLUNIFORM1FARBPROC Uniform1fARB = (PFNGLUNIFORM1FARBPROC) func;
  1774. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1775. /* This is a trivial fragment shader that sets the color of the
  1776. * fragment to the uniform value passed in.
  1777. */
  1778. static const char *fragmentShaderText =
  1779. "uniform float uniformColor;"
  1780. "void main() {gl_FragColor.r = uniformColor;}";
  1781. static const char *uniformName = "uniformColor";
  1782. GLhandleARB program;
  1783. GLint uniformLocation;
  1784. const GLfloat uniform[1] = {1.1};
  1785. GLfloat queriedUniform[1];
  1786. if (GetUniformfvARB == NULL) {
  1787. return GL_FALSE;
  1788. }
  1789. /* Call a helper function to compile up the shader and give
  1790. * us back the validated program and uniform location.
  1791. * If it fails, something's wrong and we can't continue.
  1792. */
  1793. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1794. &program, &uniformLocation)) {
  1795. return GL_FALSE;
  1796. }
  1797. /* Set the value of the program uniform. Note that you must
  1798. * use a compatible type. Our uniform above is a float
  1799. * so we must set it using float versions
  1800. * of the Uniform* functions.
  1801. */
  1802. (*Uniform1fARB)(uniformLocation, uniform[0]);
  1803. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1804. /* Query it back */
  1805. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1806. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1807. /* Clean up before we check to see whether it came back unscathed */
  1808. exercise_uniform_end(program);
  1809. /* Now check to see whether the uniform came back as expected. This
  1810. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1811. */
  1812. return compare_floats(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1813. }
  1814. static GLboolean
  1815. test_Uniform2iv(generic_func func)
  1816. {
  1817. PFNGLUNIFORM2IVARBPROC Uniform2ivARB = (PFNGLUNIFORM2IVARBPROC) func;
  1818. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1819. /* This is a trivial fragment shader that sets the color of the
  1820. * fragment to the uniform value passed in.
  1821. */
  1822. static const char *fragmentShaderText =
  1823. "uniform ivec2 uniformColor;"
  1824. "void main() {gl_FragColor.rg = uniformColor;}";
  1825. static const char *uniformName = "uniformColor";
  1826. GLhandleARB program;
  1827. GLint uniformLocation;
  1828. const GLint uniform[2] = {1,2};
  1829. GLint queriedUniform[2];
  1830. if (GetUniformivARB == NULL) {
  1831. return GL_FALSE;
  1832. }
  1833. /* Call a helper function to compile up the shader and give
  1834. * us back the validated program and uniform location.
  1835. * If it fails, something's wrong and we can't continue.
  1836. */
  1837. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1838. &program, &uniformLocation)) {
  1839. return GL_FALSE;
  1840. }
  1841. /* Set the value of the program uniform. Note that you must
  1842. * use a compatible type. Our uniform above is an integer
  1843. * vector 2 (ivec2), so we must set it using integer versions
  1844. * of the Uniform* functions. The "1" means we're setting
  1845. * one vector's worth of information.
  1846. */
  1847. (*Uniform2ivARB)(uniformLocation, 1, uniform);
  1848. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1849. /* Query it back */
  1850. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1851. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1852. /* Clean up before we check to see whether it came back unscathed */
  1853. exercise_uniform_end(program);
  1854. /* Now check to see whether the uniform came back as expected. This
  1855. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1856. */
  1857. return compare_ints(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1858. }
  1859. static GLboolean
  1860. test_Uniform2i(generic_func func)
  1861. {
  1862. PFNGLUNIFORM2IARBPROC Uniform2iARB = (PFNGLUNIFORM2IARBPROC) func;
  1863. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1864. /* This is a trivial fragment shader that sets the color of the
  1865. * fragment to the uniform value passed in.
  1866. */
  1867. static const char *fragmentShaderText =
  1868. "uniform ivec2 uniformColor;"
  1869. "void main() {gl_FragColor.rg = uniformColor;}";
  1870. static const char *uniformName = "uniformColor";
  1871. GLhandleARB program;
  1872. GLint uniformLocation;
  1873. const GLint uniform[2] = {1,2};
  1874. GLint queriedUniform[4];
  1875. if (GetUniformivARB == NULL) {
  1876. return GL_FALSE;
  1877. }
  1878. /* Call a helper function to compile up the shader and give
  1879. * us back the validated program and uniform location.
  1880. * If it fails, something's wrong and we can't continue.
  1881. */
  1882. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1883. &program, &uniformLocation)) {
  1884. return GL_FALSE;
  1885. }
  1886. /* Set the value of the program uniform. Note that you must
  1887. * use a compatible type. Our uniform above is an integer
  1888. * vector 2 (ivec2), so we must set it using integer versions
  1889. * of the Uniform* functions.
  1890. */
  1891. (*Uniform2iARB)(uniformLocation, uniform[0], uniform[1]);
  1892. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1893. /* Query it back */
  1894. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1895. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1896. /* Clean up before we check to see whether it came back unscathed */
  1897. exercise_uniform_end(program);
  1898. /* Now check to see whether the uniform came back as expected. This
  1899. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1900. */
  1901. return compare_ints(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1902. }
  1903. static GLboolean
  1904. test_Uniform2fv(generic_func func)
  1905. {
  1906. PFNGLUNIFORM2FVARBPROC Uniform2fvARB = (PFNGLUNIFORM2FVARBPROC) func;
  1907. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1908. /* This is a trivial fragment shader that sets the color of the
  1909. * fragment to the uniform value passed in.
  1910. */
  1911. static const char *fragmentShaderText =
  1912. "uniform vec2 uniformColor;"
  1913. "void main() {gl_FragColor.rg = uniformColor;}";
  1914. static const char *uniformName = "uniformColor";
  1915. GLhandleARB program;
  1916. GLint uniformLocation;
  1917. const GLfloat uniform[2] = {1.1,2.2};
  1918. GLfloat queriedUniform[2];
  1919. if (GetUniformfvARB == NULL) {
  1920. return GL_FALSE;
  1921. }
  1922. /* Call a helper function to compile up the shader and give
  1923. * us back the validated program and uniform location.
  1924. * If it fails, something's wrong and we can't continue.
  1925. */
  1926. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1927. &program, &uniformLocation)) {
  1928. return GL_FALSE;
  1929. }
  1930. /* Set the value of the program uniform. Note that you must
  1931. * use a compatible type. Our uniform above is a float
  1932. * vector 2 (vec2), so we must set it using float versions
  1933. * of the Uniform* functions. The "1" means we're setting
  1934. * one vector's worth of information.
  1935. */
  1936. (*Uniform2fvARB)(uniformLocation, 1, uniform);
  1937. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1938. /* Query it back */
  1939. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1940. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1941. /* Clean up before we check to see whether it came back unscathed */
  1942. exercise_uniform_end(program);
  1943. /* Now check to see whether the uniform came back as expected. This
  1944. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1945. */
  1946. return compare_floats(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1947. }
  1948. static GLboolean
  1949. test_Uniform2f(generic_func func)
  1950. {
  1951. PFNGLUNIFORM2FARBPROC Uniform2fARB = (PFNGLUNIFORM2FARBPROC) func;
  1952. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1953. /* This is a trivial fragment shader that sets the color of the
  1954. * fragment to the uniform value passed in.
  1955. */
  1956. static const char *fragmentShaderText =
  1957. "uniform vec2 uniformColor;"
  1958. "void main() {gl_FragColor.rg = uniformColor;}";
  1959. static const char *uniformName = "uniformColor";
  1960. GLhandleARB program;
  1961. GLint uniformLocation;
  1962. const GLfloat uniform[2] = {1.1,2.2};
  1963. GLfloat queriedUniform[2];
  1964. if (GetUniformfvARB == NULL) {
  1965. return GL_FALSE;
  1966. }
  1967. /* Call a helper function to compile up the shader and give
  1968. * us back the validated program and uniform location.
  1969. * If it fails, something's wrong and we can't continue.
  1970. */
  1971. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1972. &program, &uniformLocation)) {
  1973. return GL_FALSE;
  1974. }
  1975. /* Set the value of the program uniform. Note that you must
  1976. * use a compatible type. Our uniform above is a float
  1977. * vector 2 (vec2), so we must set it using float versions
  1978. * of the Uniform* functions.
  1979. */
  1980. (*Uniform2fARB)(uniformLocation, uniform[0], uniform[1]);
  1981. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1982. /* Query it back */
  1983. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1984. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1985. /* Clean up before we check to see whether it came back unscathed */
  1986. exercise_uniform_end(program);
  1987. /* Now check to see whether the uniform came back as expected. This
  1988. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1989. */
  1990. return compare_floats(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1991. }
  1992. static GLboolean
  1993. test_Uniform3iv(generic_func func)
  1994. {
  1995. PFNGLUNIFORM3IVARBPROC Uniform3ivARB = (PFNGLUNIFORM3IVARBPROC) func;
  1996. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1997. /* This is a trivial fragment shader that sets the color of the
  1998. * fragment to the uniform value passed in.
  1999. */
  2000. static const char *fragmentShaderText =
  2001. "uniform ivec3 uniformColor;"
  2002. "void main() {gl_FragColor.rgb = uniformColor;}";
  2003. static const char *uniformName = "uniformColor";
  2004. GLhandleARB program;
  2005. GLint uniformLocation;
  2006. const GLint uniform[3] = {1,2,3};
  2007. GLint queriedUniform[3];
  2008. if (GetUniformivARB == NULL) {
  2009. return GL_FALSE;
  2010. }
  2011. /* Call a helper function to compile up the shader and give
  2012. * us back the validated program and uniform location.
  2013. * If it fails, something's wrong and we can't continue.
  2014. */
  2015. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2016. &program, &uniformLocation)) {
  2017. return GL_FALSE;
  2018. }
  2019. /* Set the value of the program uniform. Note that you must
  2020. * use a compatible type. Our uniform above is an integer
  2021. * vector 3 (ivec3), so we must set it using integer versions
  2022. * of the Uniform* functions. The "1" means we're setting
  2023. * one vector's worth of information.
  2024. */
  2025. (*Uniform3ivARB)(uniformLocation, 1, uniform);
  2026. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2027. /* Query it back */
  2028. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2029. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2030. /* Clean up before we check to see whether it came back unscathed */
  2031. exercise_uniform_end(program);
  2032. /* Now check to see whether the uniform came back as expected. This
  2033. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2034. */
  2035. return compare_ints(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2036. }
  2037. static GLboolean
  2038. test_Uniform3i(generic_func func)
  2039. {
  2040. PFNGLUNIFORM3IARBPROC Uniform3iARB = (PFNGLUNIFORM3IARBPROC) func;
  2041. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  2042. /* This is a trivial fragment shader that sets the color of the
  2043. * fragment to the uniform value passed in.
  2044. */
  2045. static const char *fragmentShaderText =
  2046. "uniform ivec3 uniformColor;"
  2047. "void main() {gl_FragColor.rgb = uniformColor;}";
  2048. static const char *uniformName = "uniformColor";
  2049. GLhandleARB program;
  2050. GLint uniformLocation;
  2051. const GLint uniform[3] = {1,2,3};
  2052. GLint queriedUniform[4];
  2053. if (GetUniformivARB == NULL) {
  2054. return GL_FALSE;
  2055. }
  2056. /* Call a helper function to compile up the shader and give
  2057. * us back the validated program and uniform location.
  2058. * If it fails, something's wrong and we can't continue.
  2059. */
  2060. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2061. &program, &uniformLocation)) {
  2062. return GL_FALSE;
  2063. }
  2064. /* Set the value of the program uniform. Note that you must
  2065. * use a compatible type. Our uniform above is an integer
  2066. * vector 3 (ivec3), so we must set it using integer versions
  2067. * of the Uniform* functions.
  2068. */
  2069. (*Uniform3iARB)(uniformLocation, uniform[0], uniform[1], uniform[2]);
  2070. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2071. /* Query it back */
  2072. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2073. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2074. /* Clean up before we check to see whether it came back unscathed */
  2075. exercise_uniform_end(program);
  2076. /* Now check to see whether the uniform came back as expected. This
  2077. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2078. */
  2079. return compare_ints(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2080. }
  2081. static GLboolean
  2082. test_Uniform3fv(generic_func func)
  2083. {
  2084. PFNGLUNIFORM3FVARBPROC Uniform3fvARB = (PFNGLUNIFORM3FVARBPROC) func;
  2085. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2086. /* This is a trivial fragment shader that sets the color of the
  2087. * fragment to the uniform value passed in.
  2088. */
  2089. static const char *fragmentShaderText =
  2090. "uniform vec3 uniformColor;"
  2091. "void main() {gl_FragColor.rgb = uniformColor;}";
  2092. static const char *uniformName = "uniformColor";
  2093. GLhandleARB program;
  2094. GLint uniformLocation;
  2095. const GLfloat uniform[3] = {1.1,2.2,3.3};
  2096. GLfloat queriedUniform[3];
  2097. if (GetUniformfvARB == NULL) {
  2098. return GL_FALSE;
  2099. }
  2100. /* Call a helper function to compile up the shader and give
  2101. * us back the validated program and uniform location.
  2102. * If it fails, something's wrong and we can't continue.
  2103. */
  2104. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2105. &program, &uniformLocation)) {
  2106. return GL_FALSE;
  2107. }
  2108. /* Set the value of the program uniform. Note that you must
  2109. * use a compatible type. Our uniform above is a float
  2110. * vector 3 (vec3), so we must set it using float versions
  2111. * of the Uniform* functions. The "1" means we're setting
  2112. * one vector's worth of information.
  2113. */
  2114. (*Uniform3fvARB)(uniformLocation, 1, uniform);
  2115. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2116. /* Query it back */
  2117. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2118. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2119. /* Clean up before we check to see whether it came back unscathed */
  2120. exercise_uniform_end(program);
  2121. /* Now check to see whether the uniform came back as expected. This
  2122. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2123. */
  2124. return compare_floats(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2125. }
  2126. static GLboolean
  2127. test_Uniform3f(generic_func func)
  2128. {
  2129. PFNGLUNIFORM3FARBPROC Uniform3fARB = (PFNGLUNIFORM3FARBPROC) func;
  2130. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2131. /* This is a trivial fragment shader that sets the color of the
  2132. * fragment to the uniform value passed in.
  2133. */
  2134. static const char *fragmentShaderText =
  2135. "uniform vec3 uniformColor;"
  2136. "void main() {gl_FragColor.rgb = uniformColor;}";
  2137. static const char *uniformName = "uniformColor";
  2138. GLhandleARB program;
  2139. GLint uniformLocation;
  2140. const GLfloat uniform[3] = {1.1,2.2,3.3};
  2141. GLfloat queriedUniform[3];
  2142. if (GetUniformfvARB == NULL) {
  2143. return GL_FALSE;
  2144. }
  2145. /* Call a helper function to compile up the shader and give
  2146. * us back the validated program and uniform location.
  2147. * If it fails, something's wrong and we can't continue.
  2148. */
  2149. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2150. &program, &uniformLocation)) {
  2151. return GL_FALSE;
  2152. }
  2153. /* Set the value of the program uniform. Note that you must
  2154. * use a compatible type. Our uniform above is a float
  2155. * vector 3 (vec3), so we must set it using float versions
  2156. * of the Uniform* functions.
  2157. */
  2158. (*Uniform3fARB)(uniformLocation, uniform[0], uniform[1], uniform[2]);
  2159. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2160. /* Query it back */
  2161. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2162. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2163. /* Clean up before we check to see whether it came back unscathed */
  2164. exercise_uniform_end(program);
  2165. /* Now check to see whether the uniform came back as expected. This
  2166. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2167. */
  2168. return compare_floats(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2169. }
  2170. static GLboolean
  2171. test_Uniform4iv(generic_func func)
  2172. {
  2173. PFNGLUNIFORM4IVARBPROC Uniform4ivARB = (PFNGLUNIFORM4IVARBPROC) func;
  2174. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  2175. /* This is a trivial fragment shader that sets the color of the
  2176. * fragment to the uniform value passed in.
  2177. */
  2178. static const char *fragmentShaderText =
  2179. "uniform ivec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2180. static const char *uniformName = "uniformColor";
  2181. GLhandleARB program;
  2182. GLint uniformLocation;
  2183. const GLint uniform[4] = {1,2,3,4};
  2184. GLint queriedUniform[4];
  2185. if (GetUniformivARB == NULL) {
  2186. return GL_FALSE;
  2187. }
  2188. /* Call a helper function to compile up the shader and give
  2189. * us back the validated program and uniform location.
  2190. * If it fails, something's wrong and we can't continue.
  2191. */
  2192. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2193. &program, &uniformLocation)) {
  2194. return GL_FALSE;
  2195. }
  2196. /* Set the value of the program uniform. Note that you must
  2197. * use a compatible type. Our uniform above is an integer
  2198. * vector (ivec4), so we must set it using integer versions
  2199. * of the Uniform* functions. The "1" means we're setting
  2200. * one vector's worth of information.
  2201. */
  2202. (*Uniform4ivARB)(uniformLocation, 1, uniform);
  2203. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2204. /* Query it back */
  2205. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2206. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2207. /* Clean up before we check to see whether it came back unscathed */
  2208. exercise_uniform_end(program);
  2209. /* Now check to see whether the uniform came back as expected. This
  2210. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2211. */
  2212. return compare_ints(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2213. }
  2214. static GLboolean
  2215. test_Uniform4i(generic_func func)
  2216. {
  2217. PFNGLUNIFORM4IARBPROC Uniform4iARB = (PFNGLUNIFORM4IARBPROC) func;
  2218. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  2219. /* This is a trivial fragment shader that sets the color of the
  2220. * fragment to the uniform value passed in.
  2221. */
  2222. static const char *fragmentShaderText =
  2223. "uniform ivec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2224. static const char *uniformName = "uniformColor";
  2225. GLhandleARB program;
  2226. GLint uniformLocation;
  2227. const GLint uniform[4] = {1,2,3,4};
  2228. GLint queriedUniform[4];
  2229. if (GetUniformivARB == NULL) {
  2230. return GL_FALSE;
  2231. }
  2232. /* Call a helper function to compile up the shader and give
  2233. * us back the validated program and uniform location.
  2234. * If it fails, something's wrong and we can't continue.
  2235. */
  2236. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2237. &program, &uniformLocation)) {
  2238. return GL_FALSE;
  2239. }
  2240. /* Set the value of the program uniform. Note that you must
  2241. * use a compatible type. Our uniform above is an integer
  2242. * vector (ivec4), so we must set it using integer versions
  2243. * of the Uniform* functions.
  2244. */
  2245. (*Uniform4iARB)(uniformLocation, uniform[0], uniform[1], uniform[2],
  2246. uniform[3]);
  2247. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2248. /* Query it back */
  2249. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2250. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2251. /* Clean up before we check to see whether it came back unscathed */
  2252. exercise_uniform_end(program);
  2253. /* Now check to see whether the uniform came back as expected. This
  2254. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2255. */
  2256. return compare_ints(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2257. }
  2258. static GLboolean
  2259. test_Uniform4fv(generic_func func)
  2260. {
  2261. PFNGLUNIFORM4FVARBPROC Uniform4fvARB = (PFNGLUNIFORM4FVARBPROC) func;
  2262. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2263. /* This is a trivial fragment shader that sets the color of the
  2264. * fragment to the uniform value passed in.
  2265. */
  2266. static const char *fragmentShaderText =
  2267. "uniform vec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2268. static const char *uniformName = "uniformColor";
  2269. GLhandleARB program;
  2270. GLint uniformLocation;
  2271. const GLfloat uniform[4] = {1.1,2.2,3.3,4.4};
  2272. GLfloat queriedUniform[4];
  2273. if (GetUniformfvARB == NULL) {
  2274. return GL_FALSE;
  2275. }
  2276. /* Call a helper function to compile up the shader and give
  2277. * us back the validated program and uniform location.
  2278. * If it fails, something's wrong and we can't continue.
  2279. */
  2280. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2281. &program, &uniformLocation)) {
  2282. return GL_FALSE;
  2283. }
  2284. /* Set the value of the program uniform. Note that you must
  2285. * use a compatible type. Our uniform above is a float
  2286. * vector (vec4), so we must set it using float versions
  2287. * of the Uniform* functions. The "1" means we're setting
  2288. * one vector's worth of information.
  2289. */
  2290. (*Uniform4fvARB)(uniformLocation, 1, uniform);
  2291. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2292. /* Query it back */
  2293. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2294. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2295. /* Clean up before we check to see whether it came back unscathed */
  2296. exercise_uniform_end(program);
  2297. /* Now check to see whether the uniform came back as expected. This
  2298. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2299. */
  2300. return compare_floats(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2301. }
  2302. static GLboolean
  2303. test_Uniform4f(generic_func func)
  2304. {
  2305. PFNGLUNIFORM4FARBPROC Uniform4fARB = (PFNGLUNIFORM4FARBPROC) func;
  2306. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2307. /* This is a trivial fragment shader that sets the color of the
  2308. * fragment to the uniform value passed in.
  2309. */
  2310. static const char *fragmentShaderText =
  2311. "uniform vec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2312. static const char *uniformName = "uniformColor";
  2313. GLhandleARB program;
  2314. GLint uniformLocation;
  2315. const GLfloat uniform[4] = {1.1,2.2,3.3,4.4};
  2316. GLfloat queriedUniform[4];
  2317. if (GetUniformfvARB == NULL) {
  2318. return GL_FALSE;
  2319. }
  2320. /* Call a helper function to compile up the shader and give
  2321. * us back the validated program and uniform location.
  2322. * If it fails, something's wrong and we can't continue.
  2323. */
  2324. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2325. &program, &uniformLocation)) {
  2326. return GL_FALSE;
  2327. }
  2328. /* Set the value of the program uniform. Note that you must
  2329. * use a compatible type. Our uniform above is an integer
  2330. * vector (ivec4), so we must set it using integer versions
  2331. * of the Uniform* functions.
  2332. */
  2333. (*Uniform4fARB)(uniformLocation, uniform[0], uniform[1], uniform[2],
  2334. uniform[3]);
  2335. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2336. /* Query it back */
  2337. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2338. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2339. /* Clean up before we check to see whether it came back unscathed */
  2340. exercise_uniform_end(program);
  2341. /* Now check to see whether the uniform came back as expected. This
  2342. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2343. */
  2344. return compare_floats(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2345. }
  2346. static GLboolean
  2347. test_ActiveTextureARB(generic_func func)
  2348. {
  2349. PFNGLACTIVETEXTUREARBPROC activeTexture = (PFNGLACTIVETEXTUREARBPROC) func;
  2350. GLint t;
  2351. GLboolean pass;
  2352. (*activeTexture)(GL_TEXTURE1_ARB);
  2353. glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &t);
  2354. pass = (t == GL_TEXTURE1_ARB);
  2355. (*activeTexture)(GL_TEXTURE0_ARB); /* restore default */
  2356. return pass;
  2357. }
  2358. static GLboolean
  2359. test_SecondaryColor3fEXT(generic_func func)
  2360. {
  2361. PFNGLSECONDARYCOLOR3FEXTPROC secColor3f = (PFNGLSECONDARYCOLOR3FEXTPROC) func;
  2362. GLfloat color[4];
  2363. GLboolean pass;
  2364. (*secColor3f)(1.0, 1.0, 0.0);
  2365. glGetFloatv(GL_CURRENT_SECONDARY_COLOR_EXT, color);
  2366. pass = (color[0] == 1.0 && color[1] == 1.0 && color[2] == 0.0);
  2367. (*secColor3f)(0.0, 0.0, 0.0); /* restore default */
  2368. return pass;
  2369. }
  2370. static GLboolean
  2371. test_ActiveStencilFaceEXT(generic_func func)
  2372. {
  2373. PFNGLACTIVESTENCILFACEEXTPROC activeFace = (PFNGLACTIVESTENCILFACEEXTPROC) func;
  2374. GLint face;
  2375. GLboolean pass;
  2376. (*activeFace)(GL_BACK);
  2377. glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT, &face);
  2378. pass = (face == GL_BACK);
  2379. (*activeFace)(GL_FRONT); /* restore default */
  2380. return pass;
  2381. }
  2382. static GLboolean
  2383. test_VertexAttrib1fvARB(generic_func func)
  2384. {
  2385. PFNGLVERTEXATTRIB1FVARBPROC vertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) func;
  2386. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2387. const GLfloat v[1] = {25.0};
  2388. const GLfloat def[1] = {0};
  2389. GLfloat res[4];
  2390. GLboolean pass;
  2391. (*vertexAttrib1fvARB)(6, v);
  2392. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2393. pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0);
  2394. (*vertexAttrib1fvARB)(6, def);
  2395. return pass;
  2396. }
  2397. static GLboolean
  2398. test_VertexAttrib1dvARB(generic_func func)
  2399. {
  2400. PFNGLVERTEXATTRIB1DVARBPROC vertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC) func;
  2401. PFNGLGETVERTEXATTRIBDVARBPROC getVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvARB");
  2402. const GLdouble v[1] = {25.0};
  2403. const GLdouble def[1] = {0};
  2404. GLdouble res[4];
  2405. GLboolean pass;
  2406. (*vertexAttrib1dvARB)(6, v);
  2407. (*getVertexAttribdvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2408. pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0);
  2409. (*vertexAttrib1dvARB)(6, def);
  2410. return pass;
  2411. }
  2412. static GLboolean
  2413. test_VertexAttrib1svARB(generic_func func)
  2414. {
  2415. PFNGLVERTEXATTRIB1SVARBPROC vertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC) func;
  2416. PFNGLGETVERTEXATTRIBIVARBPROC getVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivARB");
  2417. const GLshort v[1] = {25.0};
  2418. const GLshort def[1] = {0};
  2419. GLint res[4];
  2420. GLboolean pass;
  2421. (*vertexAttrib1svARB)(6, v);
  2422. (*getVertexAttribivARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2423. pass = (res[0] == 25 && res[1] == 0 && res[2] == 0 && res[3] == 1);
  2424. (*vertexAttrib1svARB)(6, def);
  2425. return pass;
  2426. }
  2427. static GLboolean
  2428. test_VertexAttrib4NubvARB(generic_func func)
  2429. {
  2430. PFNGLVERTEXATTRIB4NUBVARBPROC vertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) func;
  2431. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2432. const GLubyte v[4] = {255, 0, 255, 0};
  2433. const GLubyte def[4] = {0, 0, 0, 255};
  2434. GLfloat res[4];
  2435. GLboolean pass;
  2436. (*vertexAttrib4NubvARB)(6, v);
  2437. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2438. pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0);
  2439. (*vertexAttrib4NubvARB)(6, def);
  2440. return pass;
  2441. }
  2442. static GLboolean
  2443. test_VertexAttrib4NuivARB(generic_func func)
  2444. {
  2445. PFNGLVERTEXATTRIB4NUIVARBPROC vertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) func;
  2446. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2447. const GLuint v[4] = {0xffffffff, 0, 0xffffffff, 0};
  2448. const GLuint def[4] = {0, 0, 0, 0xffffffff};
  2449. GLfloat res[4];
  2450. GLboolean pass;
  2451. (*vertexAttrib4NuivARB)(6, v);
  2452. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2453. pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
  2454. (*vertexAttrib4NuivARB)(6, def);
  2455. return pass;
  2456. }
  2457. static GLboolean
  2458. test_VertexAttrib4ivARB(generic_func func)
  2459. {
  2460. PFNGLVERTEXATTRIB4IVARBPROC vertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) func;
  2461. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2462. const GLint v[4] = {1, 2, -3, 4};
  2463. const GLint def[4] = {0, 0, 0, 1};
  2464. GLfloat res[4];
  2465. GLboolean pass;
  2466. (*vertexAttrib4ivARB)(6, v);
  2467. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2468. pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 2.0) && EQUAL(res[2], -3.0) && EQUAL(res[3], 4.0));
  2469. (*vertexAttrib4ivARB)(6, def);
  2470. return pass;
  2471. }
  2472. static GLboolean
  2473. test_VertexAttrib4NsvARB(generic_func func)
  2474. {
  2475. PFNGLVERTEXATTRIB4NSVARBPROC vertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) func;
  2476. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2477. const GLshort v[4] = {0, 32767, 32767, 0};
  2478. const GLshort def[4] = {0, 0, 0, 32767};
  2479. GLfloat res[4];
  2480. GLboolean pass;
  2481. (*vertexAttrib4NsvARB)(6, v);
  2482. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2483. pass = (EQUAL(res[0], 0.0) && EQUAL(res[1], 1.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
  2484. (*vertexAttrib4NsvARB)(6, def);
  2485. return pass;
  2486. }
  2487. static GLboolean
  2488. test_VertexAttrib4NusvARB(generic_func func)
  2489. {
  2490. PFNGLVERTEXATTRIB4NUSVARBPROC vertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) func;
  2491. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2492. const GLushort v[4] = {0xffff, 0, 0xffff, 0};
  2493. const GLushort def[4] = {0, 0, 0, 0xffff};
  2494. GLfloat res[4];
  2495. GLboolean pass;
  2496. (*vertexAttrib4NusvARB)(6, v);
  2497. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2498. pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
  2499. (*vertexAttrib4NusvARB)(6, def);
  2500. return pass;
  2501. }
  2502. static GLboolean
  2503. test_VertexAttrib1sNV(generic_func func)
  2504. {
  2505. PFNGLVERTEXATTRIB1SNVPROC vertexAttrib1sNV = (PFNGLVERTEXATTRIB1SNVPROC) func;
  2506. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2507. const GLshort v[4] = {2, 0, 0, 1};
  2508. const GLshort def[4] = {0, 0, 0, 1};
  2509. GLint res[4];
  2510. (*vertexAttrib1sNV)(6, v[0]);
  2511. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2512. (*vertexAttrib1sNV)(6, def[0]);
  2513. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2514. }
  2515. static GLboolean
  2516. test_VertexAttrib1fNV(generic_func func)
  2517. {
  2518. PFNGLVERTEXATTRIB1FNVPROC vertexAttrib1fNV = (PFNGLVERTEXATTRIB1FNVPROC) func;
  2519. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2520. const GLfloat v[4] = {2.5, 0.0, 0.0, 1.0};
  2521. const GLfloat def[4] = {0, 0, 0, 1};
  2522. GLfloat res[4];
  2523. (*vertexAttrib1fNV)(6, v[0]);
  2524. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2525. (*vertexAttrib1fNV)(6, def[0]);
  2526. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2527. }
  2528. static GLboolean
  2529. test_VertexAttrib1dNV(generic_func func)
  2530. {
  2531. PFNGLVERTEXATTRIB1DNVPROC vertexAttrib1dNV = (PFNGLVERTEXATTRIB1DNVPROC) func;
  2532. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2533. const GLdouble v[4] = {2.5, 0.0, 0.0, 1.0};
  2534. const GLdouble def[4] = {0, 0, 0, 1};
  2535. GLdouble res[4];
  2536. (*vertexAttrib1dNV)(6, v[0]);
  2537. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2538. (*vertexAttrib1dNV)(6, def[0]);
  2539. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2540. }
  2541. static GLboolean
  2542. test_VertexAttrib2sNV(generic_func func)
  2543. {
  2544. PFNGLVERTEXATTRIB2SNVPROC vertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC) func;
  2545. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2546. const GLshort v[4] = {2, 4, 0, 1};
  2547. const GLshort def[4] = {0, 0, 0, 1};
  2548. GLint res[4];
  2549. (*vertexAttrib2sNV)(6, v[0], v[1]);
  2550. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2551. (*vertexAttrib2sNV)(6, def[0], def[1]);
  2552. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2553. }
  2554. static GLboolean
  2555. test_VertexAttrib2fNV(generic_func func)
  2556. {
  2557. PFNGLVERTEXATTRIB2FNVPROC vertexAttrib2fNV = (PFNGLVERTEXATTRIB2FNVPROC) func;
  2558. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2559. const GLfloat v[4] = {2.5, 4.25, 0.0, 1.0};
  2560. const GLfloat def[4] = {0, 0, 0, 1};
  2561. GLfloat res[4];
  2562. (*vertexAttrib2fNV)(6, v[0], v[1]);
  2563. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2564. (*vertexAttrib2fNV)(6, def[0], def[1]);
  2565. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2566. }
  2567. static GLboolean
  2568. test_VertexAttrib2dNV(generic_func func)
  2569. {
  2570. PFNGLVERTEXATTRIB2DNVPROC vertexAttrib2dNV = (PFNGLVERTEXATTRIB2DNVPROC) func;
  2571. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2572. const GLdouble v[4] = {2.5, 4.25, 0.0, 1.0};
  2573. const GLdouble def[4] = {0, 0, 0, 1};
  2574. GLdouble res[4];
  2575. (*vertexAttrib2dNV)(6, v[0], v[1]);
  2576. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2577. (*vertexAttrib2dNV)(6, def[0], def[1]);
  2578. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2579. }
  2580. static GLboolean
  2581. test_VertexAttrib3sNV(generic_func func)
  2582. {
  2583. PFNGLVERTEXATTRIB3SNVPROC vertexAttrib3sNV = (PFNGLVERTEXATTRIB3SNVPROC) func;
  2584. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2585. const GLshort v[4] = {2, 4, 7, 1};
  2586. const GLshort def[4] = {0, 0, 0, 1};
  2587. GLint res[4];
  2588. (*vertexAttrib3sNV)(6, v[0], v[1], v[2]);
  2589. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2590. (*vertexAttrib3sNV)(6, def[0], def[1], def[2]);
  2591. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2592. }
  2593. static GLboolean
  2594. test_VertexAttrib3fNV(generic_func func)
  2595. {
  2596. PFNGLVERTEXATTRIB3FNVPROC vertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC) func;
  2597. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2598. const GLfloat v[4] = {2.5, 4.25, 7.125, 1.0};
  2599. const GLfloat def[4] = {0, 0, 0, 1};
  2600. GLfloat res[4];
  2601. (*vertexAttrib3fNV)(6, v[0], v[1], v[2]);
  2602. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2603. (*vertexAttrib3fNV)(6, def[0], def[1], def[2]);
  2604. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2605. }
  2606. static GLboolean
  2607. test_VertexAttrib3dNV(generic_func func)
  2608. {
  2609. PFNGLVERTEXATTRIB3DNVPROC vertexAttrib3dNV = (PFNGLVERTEXATTRIB3DNVPROC) func;
  2610. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2611. const GLdouble v[4] = {2.5, 4.25, 7.125, 1.0};
  2612. const GLdouble def[4] = {0, 0, 0, 1};
  2613. GLdouble res[4];
  2614. (*vertexAttrib3dNV)(6, v[0], v[1], v[2]);
  2615. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2616. (*vertexAttrib3dNV)(6, def[0], def[1], def[2]);
  2617. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2618. }
  2619. static GLboolean
  2620. test_VertexAttrib4sNV(generic_func func)
  2621. {
  2622. PFNGLVERTEXATTRIB4SNVPROC vertexAttrib4sNV = (PFNGLVERTEXATTRIB4SNVPROC) func;
  2623. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2624. const GLshort v[4] = {2, 4, 7, 5};
  2625. const GLshort def[4] = {0, 0, 0, 1};
  2626. GLint res[4];
  2627. (*vertexAttrib4sNV)(6, v[0], v[1], v[2], v[3]);
  2628. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2629. (*vertexAttrib4sNV)(6, def[0], def[1], def[2], def[3]);
  2630. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2631. }
  2632. static GLboolean
  2633. test_VertexAttrib4fNV(generic_func func)
  2634. {
  2635. PFNGLVERTEXATTRIB4FNVPROC vertexAttrib4fNV = (PFNGLVERTEXATTRIB4FNVPROC) func;
  2636. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2637. const GLfloat v[4] = {2.5, 4.25, 7.125, 5.0625};
  2638. const GLfloat def[4] = {0, 0, 0, 1};
  2639. GLfloat res[4];
  2640. (*vertexAttrib4fNV)(6, v[0], v[1], v[2], v[3]);
  2641. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2642. (*vertexAttrib4fNV)(6, def[0], def[1], def[2], def[3]);
  2643. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2644. }
  2645. static GLboolean
  2646. test_VertexAttrib4dNV(generic_func func)
  2647. {
  2648. PFNGLVERTEXATTRIB4DNVPROC vertexAttrib4dNV = (PFNGLVERTEXATTRIB4DNVPROC) func;
  2649. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2650. const GLdouble v[4] = {2.5, 4.25, 7.125, 5.0625};
  2651. const GLdouble def[4] = {0, 0, 0, 1};
  2652. GLdouble res[4];
  2653. (*vertexAttrib4dNV)(6, v[0], v[1], v[2], v[3]);
  2654. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2655. (*vertexAttrib4dNV)(6, def[0], def[1], def[2], def[3]);
  2656. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2657. }
  2658. static GLboolean
  2659. test_VertexAttrib4ubNV(generic_func func)
  2660. {
  2661. PFNGLVERTEXATTRIB4UBNVPROC vertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC) func;
  2662. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2663. const GLubyte v[4] = {255, 0, 255, 0};
  2664. const GLubyte def[4] = {0, 0, 0, 255};
  2665. GLfloat res[4];
  2666. /* There's no byte-value query; so we use the float-value query.
  2667. * Bytes are interpreted as steps between 0 and 1, so the
  2668. * expected float values will be 0.0 for byte value 0 and 1.0 for
  2669. * byte value 255.
  2670. */
  2671. GLfloat expectedResults[4] = {1.0, 0.0, 1.0, 0.0};
  2672. (*vertexAttrib4ubNV)(6, v[0], v[1], v[2], v[3]);
  2673. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2674. (*vertexAttrib4ubNV)(6, def[0], def[1], def[2], def[3]);
  2675. return compare_floats(__FUNCTION__, 4, expectedResults, 4, res);
  2676. }
  2677. static GLboolean
  2678. test_VertexAttrib1fvNV(generic_func func)
  2679. {
  2680. PFNGLVERTEXATTRIB1FVNVPROC vertexAttrib1fvNV = (PFNGLVERTEXATTRIB1FVNVPROC) func;
  2681. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2682. const GLfloat v[4] = {2.5, 0.0, 0.0, 1.0};
  2683. const GLfloat def[4] = {0, 0, 0, 1};
  2684. GLfloat res[4];
  2685. (*vertexAttrib1fvNV)(6, v);
  2686. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2687. (*vertexAttrib1fvNV)(6, def);
  2688. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2689. }
  2690. static GLboolean
  2691. test_VertexAttrib1dvNV(generic_func func)
  2692. {
  2693. PFNGLVERTEXATTRIB1DVNVPROC vertexAttrib1dvNV = (PFNGLVERTEXATTRIB1DVNVPROC) func;
  2694. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2695. const GLdouble v[4] = {2.5, 0.0, 0.0, 1.0};
  2696. const GLdouble def[4] = {0, 0, 0, 1};
  2697. GLdouble res[4];
  2698. (*vertexAttrib1dvNV)(6, v);
  2699. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2700. (*vertexAttrib1dvNV)(6, def);
  2701. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2702. }
  2703. static GLboolean
  2704. test_VertexAttrib2svNV(generic_func func)
  2705. {
  2706. PFNGLVERTEXATTRIB2SVNVPROC vertexAttrib2svNV = (PFNGLVERTEXATTRIB2SVNVPROC) func;
  2707. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2708. const GLshort v[4] = {2, 4, 0, 1};
  2709. const GLshort def[4] = {0, 0, 0, 1};
  2710. GLint res[4];
  2711. (*vertexAttrib2svNV)(6, v);
  2712. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2713. (*vertexAttrib2svNV)(6, def);
  2714. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2715. }
  2716. static GLboolean
  2717. test_VertexAttrib2fvNV(generic_func func)
  2718. {
  2719. PFNGLVERTEXATTRIB2FVNVPROC vertexAttrib2fvNV = (PFNGLVERTEXATTRIB2FVNVPROC) func;
  2720. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2721. const GLfloat v[4] = {2.5, 4.25, 0.0, 1.0};
  2722. const GLfloat def[4] = {0, 0, 0, 1};
  2723. GLfloat res[4];
  2724. (*vertexAttrib2fvNV)(6, v);
  2725. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2726. (*vertexAttrib2fvNV)(6, def);
  2727. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2728. }
  2729. static GLboolean
  2730. test_VertexAttrib2dvNV(generic_func func)
  2731. {
  2732. PFNGLVERTEXATTRIB2DVNVPROC vertexAttrib2dvNV = (PFNGLVERTEXATTRIB2DVNVPROC) func;
  2733. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2734. const GLdouble v[4] = {2.5, 4.25, 0.0, 1.0};
  2735. const GLdouble def[4] = {0, 0, 0, 1};
  2736. GLdouble res[4];
  2737. (*vertexAttrib2dvNV)(6, v);
  2738. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2739. (*vertexAttrib2dvNV)(6, def);
  2740. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2741. }
  2742. static GLboolean
  2743. test_VertexAttrib3svNV(generic_func func)
  2744. {
  2745. PFNGLVERTEXATTRIB3SVNVPROC vertexAttrib3svNV = (PFNGLVERTEXATTRIB3SVNVPROC) func;
  2746. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2747. const GLshort v[4] = {2, 4, 7, 1};
  2748. const GLshort def[4] = {0, 0, 0, 1};
  2749. GLint res[4];
  2750. (*vertexAttrib3svNV)(6, v);
  2751. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2752. (*vertexAttrib3svNV)(6, def);
  2753. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2754. }
  2755. static GLboolean
  2756. test_VertexAttrib3fvNV(generic_func func)
  2757. {
  2758. PFNGLVERTEXATTRIB3FVNVPROC vertexAttrib3fvNV = (PFNGLVERTEXATTRIB3FVNVPROC) func;
  2759. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2760. const GLfloat v[4] = {2.5, 4.25, 7.125, 1.0};
  2761. const GLfloat def[4] = {0, 0, 0, 1};
  2762. GLfloat res[4];
  2763. (*vertexAttrib3fvNV)(6, v);
  2764. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2765. (*vertexAttrib3fvNV)(6, def);
  2766. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2767. }
  2768. static GLboolean
  2769. test_VertexAttrib3dvNV(generic_func func)
  2770. {
  2771. PFNGLVERTEXATTRIB3DVNVPROC vertexAttrib3dvNV = (PFNGLVERTEXATTRIB3DVNVPROC) func;
  2772. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2773. const GLdouble v[4] = {2.5, 4.25, 7.125, 1.0};
  2774. const GLdouble def[4] = {0, 0, 0, 1};
  2775. GLdouble res[4];
  2776. (*vertexAttrib3dvNV)(6, v);
  2777. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2778. (*vertexAttrib3dvNV)(6, def);
  2779. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2780. }
  2781. static GLboolean
  2782. test_VertexAttrib4svNV(generic_func func)
  2783. {
  2784. PFNGLVERTEXATTRIB4SVNVPROC vertexAttrib4svNV = (PFNGLVERTEXATTRIB4SVNVPROC) func;
  2785. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2786. const GLshort v[4] = {2, 4, 7, 5};
  2787. const GLshort def[4] = {0, 0, 0, 1};
  2788. GLint res[4];
  2789. (*vertexAttrib4svNV)(6, v);
  2790. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2791. (*vertexAttrib4svNV)(6, def);
  2792. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2793. }
  2794. static GLboolean
  2795. test_VertexAttrib4fvNV(generic_func func)
  2796. {
  2797. PFNGLVERTEXATTRIB4FVNVPROC vertexAttrib4fvNV = (PFNGLVERTEXATTRIB4FVNVPROC) func;
  2798. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2799. const GLfloat v[4] = {2.5, 4.25, 7.125, 5.0625};
  2800. const GLfloat def[4] = {0, 0, 0, 1};
  2801. GLfloat res[4];
  2802. (*vertexAttrib4fvNV)(6, v);
  2803. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2804. (*vertexAttrib4fvNV)(6, def);
  2805. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2806. }
  2807. static GLboolean
  2808. test_VertexAttrib4dvNV(generic_func func)
  2809. {
  2810. PFNGLVERTEXATTRIB4DVNVPROC vertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC) func;
  2811. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2812. const GLdouble v[4] = {2.5, 4.25, 7.125, 5.0625};
  2813. const GLdouble def[4] = {0, 0, 0, 1};
  2814. GLdouble res[4];
  2815. (*vertexAttrib4dvNV)(6, v);
  2816. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2817. (*vertexAttrib4dvNV)(6, def);
  2818. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2819. }
  2820. static GLboolean
  2821. test_VertexAttrib4ubvNV(generic_func func)
  2822. {
  2823. PFNGLVERTEXATTRIB4UBVNVPROC vertexAttrib4ubvNV = (PFNGLVERTEXATTRIB4UBVNVPROC) func;
  2824. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2825. const GLubyte v[4] = {255, 0, 255, 0};
  2826. const GLubyte def[4] = {0, 0, 0, 255};
  2827. GLfloat res[4];
  2828. /* There's no byte-value query; so we use the float-value query.
  2829. * Bytes are interpreted as steps between 0 and 1, so the
  2830. * expected float values will be 0.0 for byte value 0 and 1.0 for
  2831. * byte value 255.
  2832. */
  2833. GLfloat expectedResults[4] = {1.0, 0.0, 1.0, 0.0};
  2834. (*vertexAttrib4ubvNV)(6, v);
  2835. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2836. (*vertexAttrib4ubvNV)(6, def);
  2837. return compare_floats(__FUNCTION__, 4, expectedResults, 4, res);
  2838. }
  2839. static GLboolean
  2840. test_VertexAttribs1fvNV(generic_func func)
  2841. {
  2842. PFNGLVERTEXATTRIBS1FVNVPROC vertexAttribs1fvNV = (PFNGLVERTEXATTRIBS1FVNVPROC) func;
  2843. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2844. const GLfloat v[4] = {2.5, 0.0, 0.0, 1.0};
  2845. const GLfloat def[4] = {0, 0, 0, 1};
  2846. GLfloat res[4];
  2847. (*vertexAttribs1fvNV)(6, 1, v);
  2848. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2849. (*vertexAttribs1fvNV)(6, 1, def);
  2850. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2851. }
  2852. static GLboolean
  2853. test_VertexAttribs1dvNV(generic_func func)
  2854. {
  2855. PFNGLVERTEXATTRIBS1DVNVPROC vertexAttribs1dvNV = (PFNGLVERTEXATTRIBS1DVNVPROC) func;
  2856. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2857. const GLdouble v[4] = {2.5, 0.0, 0.0, 1.0};
  2858. const GLdouble def[4] = {0, 0, 0, 1};
  2859. GLdouble res[4];
  2860. (*vertexAttribs1dvNV)(6, 1, v);
  2861. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2862. (*vertexAttribs1dvNV)(6, 1, def);
  2863. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2864. }
  2865. static GLboolean
  2866. test_VertexAttribs2svNV(generic_func func)
  2867. {
  2868. PFNGLVERTEXATTRIBS2SVNVPROC vertexAttribs2svNV = (PFNGLVERTEXATTRIBS2SVNVPROC) func;
  2869. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2870. const GLshort v[4] = {2, 4, 0, 1};
  2871. const GLshort def[4] = {0, 0, 0, 1};
  2872. GLint res[4];
  2873. (*vertexAttribs2svNV)(6, 1, v);
  2874. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2875. (*vertexAttribs2svNV)(6, 1, def);
  2876. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2877. }
  2878. static GLboolean
  2879. test_VertexAttribs2fvNV(generic_func func)
  2880. {
  2881. PFNGLVERTEXATTRIBS2FVNVPROC vertexAttribs2fvNV = (PFNGLVERTEXATTRIBS2FVNVPROC) func;
  2882. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2883. const GLfloat v[4] = {2.5, 4.25, 0.0, 1.0};
  2884. const GLfloat def[4] = {0, 0, 0, 1};
  2885. GLfloat res[4];
  2886. (*vertexAttribs2fvNV)(6, 1, v);
  2887. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2888. (*vertexAttribs2fvNV)(6, 1, def);
  2889. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2890. }
  2891. static GLboolean
  2892. test_VertexAttribs2dvNV(generic_func func)
  2893. {
  2894. PFNGLVERTEXATTRIBS2DVNVPROC vertexAttribs2dvNV = (PFNGLVERTEXATTRIBS2DVNVPROC) func;
  2895. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2896. const GLdouble v[4] = {2.5, 4.25, 0.0, 1.0};
  2897. const GLdouble def[4] = {0, 0, 0, 1};
  2898. GLdouble res[4];
  2899. (*vertexAttribs2dvNV)(6, 1, v);
  2900. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2901. (*vertexAttribs2dvNV)(6, 1, def);
  2902. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2903. }
  2904. static GLboolean
  2905. test_VertexAttribs3svNV(generic_func func)
  2906. {
  2907. PFNGLVERTEXATTRIBS3SVNVPROC vertexAttribs3svNV = (PFNGLVERTEXATTRIBS3SVNVPROC) func;
  2908. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2909. const GLshort v[4] = {2, 4, 7, 1};
  2910. const GLshort def[4] = {0, 0, 0, 1};
  2911. GLint res[4];
  2912. (*vertexAttribs3svNV)(6, 1, v);
  2913. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2914. (*vertexAttribs3svNV)(6, 1, def);
  2915. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2916. }
  2917. static GLboolean
  2918. test_VertexAttribs3fvNV(generic_func func)
  2919. {
  2920. PFNGLVERTEXATTRIBS3FVNVPROC vertexAttribs3fvNV = (PFNGLVERTEXATTRIBS3FVNVPROC) func;
  2921. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2922. const GLfloat v[4] = {2.5, 4.25, 7.125, 1.0};
  2923. const GLfloat def[4] = {0, 0, 0, 1};
  2924. GLfloat res[4];
  2925. (*vertexAttribs3fvNV)(6, 1, v);
  2926. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2927. (*vertexAttribs3fvNV)(6, 1, def);
  2928. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2929. }
  2930. static GLboolean
  2931. test_VertexAttribs3dvNV(generic_func func)
  2932. {
  2933. PFNGLVERTEXATTRIBS3DVNVPROC vertexAttribs3dvNV = (PFNGLVERTEXATTRIBS3DVNVPROC) func;
  2934. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2935. const GLdouble v[4] = {2.5, 4.25, 7.125, 1.0};
  2936. const GLdouble def[4] = {0, 0, 0, 1};
  2937. GLdouble res[4];
  2938. (*vertexAttribs3dvNV)(6, 1, v);
  2939. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2940. (*vertexAttribs3dvNV)(6, 1, def);
  2941. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2942. }
  2943. static GLboolean
  2944. test_VertexAttribs4svNV(generic_func func)
  2945. {
  2946. PFNGLVERTEXATTRIBS4SVNVPROC vertexAttribs4svNV = (PFNGLVERTEXATTRIBS4SVNVPROC) func;
  2947. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2948. const GLshort v[4] = {2, 4, 7, 5};
  2949. const GLshort def[4] = {0, 0, 0, 1};
  2950. GLint res[4];
  2951. (*vertexAttribs4svNV)(6, 1, v);
  2952. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2953. (*vertexAttribs4svNV)(6, 1, def);
  2954. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2955. }
  2956. static GLboolean
  2957. test_VertexAttribs4fvNV(generic_func func)
  2958. {
  2959. PFNGLVERTEXATTRIBS4FVNVPROC vertexAttribs4fvNV = (PFNGLVERTEXATTRIBS4FVNVPROC) func;
  2960. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2961. const GLfloat v[4] = {2.5, 4.25, 7.125, 5.0625};
  2962. const GLfloat def[4] = {0, 0, 0, 1};
  2963. GLfloat res[4];
  2964. (*vertexAttribs4fvNV)(6, 1, v);
  2965. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2966. (*vertexAttribs4fvNV)(6, 1, def);
  2967. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2968. }
  2969. static GLboolean
  2970. test_VertexAttribs4dvNV(generic_func func)
  2971. {
  2972. PFNGLVERTEXATTRIBS4DVNVPROC vertexAttribs4dvNV = (PFNGLVERTEXATTRIBS4DVNVPROC) func;
  2973. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2974. const GLdouble v[4] = {2.5, 4.25, 7.125, 5.0625};
  2975. const GLdouble def[4] = {0, 0, 0, 1};
  2976. GLdouble res[4];
  2977. (*vertexAttribs4dvNV)(6, 1, v);
  2978. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2979. (*vertexAttribs4dvNV)(6, 1, def);
  2980. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2981. }
  2982. static GLboolean
  2983. test_VertexAttribs4ubvNV(generic_func func)
  2984. {
  2985. PFNGLVERTEXATTRIBS4UBVNVPROC vertexAttribs4ubvNV = (PFNGLVERTEXATTRIBS4UBVNVPROC) func;
  2986. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2987. const GLubyte v[4] = {255, 0, 255, 0};
  2988. const GLubyte def[4] = {0, 0, 0, 255};
  2989. GLfloat res[4];
  2990. /* There's no byte-value query; so we use the float-value query.
  2991. * Bytes are interpreted as steps between 0 and 1, so the
  2992. * expected float values will be 0.0 for byte value 0 and 1.0 for
  2993. * byte value 255.
  2994. */
  2995. GLfloat expectedResults[4] = {1.0, 0.0, 1.0, 0.0};
  2996. (*vertexAttribs4ubvNV)(6, 1, v);
  2997. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2998. (*vertexAttribs4ubvNV)(6, 1, def);
  2999. return compare_floats(__FUNCTION__, 4, expectedResults, 4, res);
  3000. }
  3001. static GLboolean
  3002. test_StencilFuncSeparateATI(generic_func func)
  3003. {
  3004. #ifdef GL_ATI_separate_stencil
  3005. PFNGLSTENCILFUNCSEPARATEATIPROC stencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) func;
  3006. GLint frontFunc, backFunc;
  3007. GLint frontRef, backRef;
  3008. GLint frontMask, backMask;
  3009. (*stencilFuncSeparateATI)(GL_LESS, GL_GREATER, 2, 0xa);
  3010. glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
  3011. glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
  3012. glGetIntegerv(GL_STENCIL_REF, &frontRef);
  3013. glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
  3014. glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
  3015. glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
  3016. if (frontFunc != GL_LESS ||
  3017. backFunc != GL_GREATER ||
  3018. frontRef != 2 ||
  3019. backRef != 2 ||
  3020. frontMask != 0xa ||
  3021. backMask != 0xa)
  3022. return GL_FALSE;
  3023. #endif
  3024. return GL_TRUE;
  3025. }
  3026. static GLboolean
  3027. test_StencilFuncSeparate(generic_func func)
  3028. {
  3029. #ifdef GL_VERSION_2_0
  3030. PFNGLSTENCILFUNCSEPARATEPROC stencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) func;
  3031. GLint frontFunc, backFunc;
  3032. GLint frontRef, backRef;
  3033. GLint frontMask, backMask;
  3034. (*stencilFuncSeparate)(GL_BACK, GL_GREATER, 2, 0xa);
  3035. glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
  3036. glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
  3037. glGetIntegerv(GL_STENCIL_REF, &frontRef);
  3038. glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
  3039. glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
  3040. glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
  3041. if (frontFunc != GL_ALWAYS ||
  3042. backFunc != GL_GREATER ||
  3043. frontRef != 0 ||
  3044. backRef != 2 ||
  3045. frontMask == 0xa || /* might be 0xff or ~0 */
  3046. backMask != 0xa)
  3047. return GL_FALSE;
  3048. #endif
  3049. return GL_TRUE;
  3050. }
  3051. static GLboolean
  3052. test_StencilOpSeparate(generic_func func)
  3053. {
  3054. #ifdef GL_VERSION_2_0
  3055. PFNGLSTENCILOPSEPARATEPROC stencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) func;
  3056. GLint frontFail, backFail;
  3057. GLint frontZFail, backZFail;
  3058. GLint frontZPass, backZPass;
  3059. (*stencilOpSeparate)(GL_BACK, GL_INCR, GL_DECR, GL_INVERT);
  3060. glGetIntegerv(GL_STENCIL_FAIL, &frontFail);
  3061. glGetIntegerv(GL_STENCIL_BACK_FAIL, &backFail);
  3062. glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &frontZFail);
  3063. glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, &backZFail);
  3064. glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &frontZPass);
  3065. glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, &backZPass);
  3066. if (frontFail != GL_KEEP ||
  3067. backFail != GL_INCR ||
  3068. frontZFail != GL_KEEP ||
  3069. backZFail != GL_DECR ||
  3070. frontZPass != GL_KEEP ||
  3071. backZPass != GL_INVERT)
  3072. return GL_FALSE;
  3073. #endif
  3074. return GL_TRUE;
  3075. }
  3076. static GLboolean
  3077. test_StencilMaskSeparate(generic_func func)
  3078. {
  3079. #ifdef GL_VERSION_2_0
  3080. PFNGLSTENCILMASKSEPARATEPROC stencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) func;
  3081. GLint frontMask, backMask;
  3082. (*stencilMaskSeparate)(GL_BACK, 0x1b);
  3083. glGetIntegerv(GL_STENCIL_WRITEMASK, &frontMask);
  3084. glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, &backMask);
  3085. if (frontMask == 0x1b ||
  3086. backMask != 0x1b)
  3087. return GL_FALSE;
  3088. #endif
  3089. return GL_TRUE;
  3090. }
  3091. /*
  3092. * The following file is auto-generated with Python.
  3093. */
  3094. #include "getproclist.h"
  3095. static int
  3096. extension_supported(const char *haystack, const char *needle)
  3097. {
  3098. const char *p = strstr(haystack, needle);
  3099. if (p) {
  3100. /* found string, make sure next char is space or zero */
  3101. const int len = strlen(needle);
  3102. if (p[len] == ' ' || p[len] == 0)
  3103. return 1;
  3104. else
  3105. return 0;
  3106. }
  3107. else
  3108. return 0;
  3109. }
  3110. /* Run all the known extension function tests, if the extension is supported.
  3111. * Return a count of how many failed.
  3112. */
  3113. static int
  3114. check_functions( const char *extensions )
  3115. {
  3116. struct name_test_pair *entry;
  3117. int failures = 0, passes = 0, untested = 0;
  3118. int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0;
  3119. int doTests = 0;
  3120. const char *version = (const char *) glGetString(GL_VERSION);
  3121. /* The functions list will have "real" entries (consisting of
  3122. * a GL function name and a pointer to an exercise function for
  3123. * that GL function), and "group" entries (indicated as
  3124. * such by having a "-" as the first character of the name).
  3125. * "Group" names always start with the "-" character, and can
  3126. * be numeric (e.g. "-1.0", "-2.1"), indicating that a particular
  3127. * OpenGL version is required for the following functions; or can be
  3128. * an extension name (e.g. "-GL_ARB_multitexture") that means
  3129. * that the named extension is required for the following functions.
  3130. */
  3131. for (entry = functions; entry->name; entry++) {
  3132. /* Check if this is a group indicator */
  3133. if (entry->name[0] == '-') {
  3134. /* A group indicator; check if it's an OpenGL version group */
  3135. if (entry->name[1] == '1') {
  3136. /* check GL version 1.x */
  3137. if (version[0] == '1' &&
  3138. version[1] == '.' &&
  3139. version[2] >= entry->name[3])
  3140. doTests = 1;
  3141. else
  3142. doTests = 0;
  3143. }
  3144. else if (entry->name[1] == '2') {
  3145. if (version[0] == '2' &&
  3146. version[1] == '.' &&
  3147. version[2] >= entry->name[3])
  3148. doTests = 1;
  3149. else
  3150. doTests = 0;
  3151. }
  3152. else {
  3153. /* check if the named extension is available */
  3154. doTests = extension_supported(extensions, entry->name+1);
  3155. }
  3156. /* doTests is now set if we're starting an OpenGL version
  3157. * group, and the running OpenGL version is at least the
  3158. * version required; or if we're starting an OpenGL extension
  3159. * group, and the extension is supported.
  3160. */
  3161. if (doTests)
  3162. printf("Testing %s functions\n", entry->name + 1);
  3163. /* Each time we hit a title function, reset the function
  3164. * counts.
  3165. */
  3166. failures = 0;
  3167. passes = 0;
  3168. untested = 0;
  3169. }
  3170. else if (doTests) {
  3171. /* Here, we know we're trying to exercise a function for
  3172. * a supported extension. See whether we have a test for
  3173. * it, and try to run it.
  3174. */
  3175. generic_func funcPtr = (generic_func) glXGetProcAddressARB((const GLubyte *) entry->name);
  3176. if (funcPtr) {
  3177. if (entry->test) {
  3178. GLboolean b;
  3179. printf(" Validating %s:", entry->name);
  3180. b = (*entry->test)(funcPtr);
  3181. if (b) {
  3182. printf(" Pass\n");
  3183. passes++;
  3184. totalPass++;
  3185. }
  3186. else {
  3187. printf(" FAIL!!!\n");
  3188. failures++;
  3189. totalFail++;
  3190. }
  3191. }
  3192. else {
  3193. untested++;
  3194. totalUntested++;
  3195. }
  3196. }
  3197. else {
  3198. printf(" glXGetProcAddress(%s) failed!\n", entry->name);
  3199. failures++;
  3200. totalFail++;
  3201. }
  3202. }
  3203. else {
  3204. /* Here, we have a function that belongs to a group that
  3205. * is known to be unsupported.
  3206. */
  3207. totalUnsupported++;
  3208. }
  3209. /* Make sure a poor test case doesn't leave any lingering
  3210. * OpenGL errors.
  3211. */
  3212. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  3213. if (doTests && (!(entry+1)->name || (entry+1)->name[0] == '-')) {
  3214. if (failures > 0) {
  3215. printf(" %d failed.\n", failures);
  3216. }
  3217. if (passes > 0) {
  3218. printf(" %d passed.\n", passes);
  3219. }
  3220. if (untested > 0) {
  3221. printf(" %d untested.\n", untested);
  3222. }
  3223. }
  3224. }
  3225. printf("-----------------------------\n");
  3226. printf("Total: %d pass %d fail %d untested %d unsupported %d total\n",
  3227. totalPass, totalFail, totalUntested, totalUnsupported,
  3228. totalPass + totalFail + totalUntested + totalUnsupported);
  3229. return totalFail;
  3230. }
  3231. /* Return an error code */
  3232. #define ERROR_NONE 0
  3233. #define ERROR_NO_VISUAL 1
  3234. #define ERROR_NO_CONTEXT 2
  3235. #define ERROR_NO_MAKECURRENT 3
  3236. #define ERROR_FAILED 4
  3237. static int
  3238. print_screen_info(Display *dpy, int scrnum, Bool allowDirect)
  3239. {
  3240. Window win;
  3241. int attribSingle[] = {
  3242. GLX_RGBA,
  3243. GLX_RED_SIZE, 1,
  3244. GLX_GREEN_SIZE, 1,
  3245. GLX_BLUE_SIZE, 1,
  3246. GLX_STENCIL_SIZE, 1,
  3247. None };
  3248. int attribDouble[] = {
  3249. GLX_RGBA,
  3250. GLX_RED_SIZE, 1,
  3251. GLX_GREEN_SIZE, 1,
  3252. GLX_BLUE_SIZE, 1,
  3253. GLX_STENCIL_SIZE, 1,
  3254. GLX_DOUBLEBUFFER,
  3255. None };
  3256. XSetWindowAttributes attr;
  3257. unsigned long mask;
  3258. Window root;
  3259. GLXContext ctx;
  3260. XVisualInfo *visinfo;
  3261. int width = 100, height = 100;
  3262. int failures;
  3263. root = RootWindow(dpy, scrnum);
  3264. visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
  3265. if (!visinfo) {
  3266. visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
  3267. if (!visinfo) {
  3268. fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
  3269. return ERROR_NO_VISUAL;
  3270. }
  3271. }
  3272. attr.background_pixel = 0;
  3273. attr.border_pixel = 0;
  3274. attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
  3275. attr.event_mask = StructureNotifyMask | ExposureMask;
  3276. mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
  3277. win = XCreateWindow(dpy, root, 0, 0, width, height,
  3278. 0, visinfo->depth, InputOutput,
  3279. visinfo->visual, mask, &attr);
  3280. ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
  3281. if (!ctx) {
  3282. fprintf(stderr, "Error: glXCreateContext failed\n");
  3283. XDestroyWindow(dpy, win);
  3284. return ERROR_NO_CONTEXT;
  3285. }
  3286. if (!glXMakeCurrent(dpy, win, ctx)) {
  3287. fprintf(stderr, "Error: glXMakeCurrent failed\n");
  3288. glXDestroyContext(dpy, ctx);
  3289. XDestroyWindow(dpy, win);
  3290. return ERROR_NO_MAKECURRENT;
  3291. }
  3292. failures = check_functions( (const char *) glGetString(GL_EXTENSIONS) );
  3293. glXDestroyContext(dpy, ctx);
  3294. XDestroyWindow(dpy, win);
  3295. return (failures == 0 ? ERROR_NONE : ERROR_FAILED);
  3296. }
  3297. int
  3298. main(int argc, char *argv[])
  3299. {
  3300. char *displayName = NULL;
  3301. Display *dpy;
  3302. int returnCode;
  3303. dpy = XOpenDisplay(displayName);
  3304. if (!dpy) {
  3305. fprintf(stderr, "Error: unable to open display %s\n", displayName);
  3306. return -1;
  3307. }
  3308. returnCode = print_screen_info(dpy, 0, GL_TRUE);
  3309. XCloseDisplay(dpy);
  3310. return returnCode;
  3311. }