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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734
  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. /* Get the function pointers we need. These are from
  1078. * GL_ARB_vertex_buffer_object and are required in all
  1079. * cases.
  1080. */
  1081. DECLARE_GLFUNC_PTR(GenBuffersARB, PFNGLGENBUFFERSARBPROC);
  1082. DECLARE_GLFUNC_PTR(BindBufferARB, PFNGLBINDBUFFERARBPROC);
  1083. DECLARE_GLFUNC_PTR(BufferDataARB, PFNGLBUFFERDATAARBPROC);
  1084. DECLARE_GLFUNC_PTR(MapBufferARB, PFNGLMAPBUFFERARBPROC);
  1085. DECLARE_GLFUNC_PTR(UnmapBufferARB, PFNGLUNMAPBUFFERARBPROC);
  1086. DECLARE_GLFUNC_PTR(DeleteBuffersARB, PFNGLDELETEBUFFERSARBPROC);
  1087. DECLARE_GLFUNC_PTR(GetBufferParameterivARB, PFNGLGETBUFFERPARAMETERIVARBPROC);
  1088. /* These are from GL_ARB_map_buffer_range, and are optional
  1089. * unless we're given Use_Map_Buffer_Range. Note that they do *not*
  1090. * have the standard "ARB" suffixes; this is because the extension
  1091. * was introduced *after* a superset was standardized in OpenGL 3.0.
  1092. * (The extension really only exists to allow the functionality on
  1093. * devices that cannot implement a full OpenGL 3.0 driver.)
  1094. */
  1095. DECLARE_GLFUNC_PTR(FlushMappedBufferRange, PFNGLFLUSHMAPPEDBUFFERRANGEPROC);
  1096. DECLARE_GLFUNC_PTR(MapBufferRange, PFNGLMAPBUFFERRANGEPROC);
  1097. /* This is from APPLE_flush_buffer_range, and is optional even if
  1098. * we're given Use_Map_Buffer_Range. Test it before using it.
  1099. */
  1100. DECLARE_GLFUNC_PTR(BufferParameteriAPPLE, PFNGLBUFFERPARAMETERIAPPLEPROC);
  1101. /* Make sure we have all the function pointers we need. */
  1102. if (GenBuffersARB == NULL ||
  1103. BindBufferARB == NULL ||
  1104. BufferDataARB == NULL ||
  1105. MapBufferARB == NULL ||
  1106. UnmapBufferARB == NULL ||
  1107. DeleteBuffersARB == NULL ||
  1108. GetBufferParameterivARB == NULL) {
  1109. fprintf(stderr, "%s: missing basic MapBuffer functions\n", __FUNCTION__);
  1110. return GL_FALSE;
  1111. }
  1112. if (usage == Use_Map_Buffer_Range) {
  1113. if (FlushMappedBufferRange == NULL || MapBufferRange == NULL) {
  1114. fprintf(stderr, "%s: missing MapBufferRange functions\n", __FUNCTION__);
  1115. return GL_FALSE;
  1116. }
  1117. }
  1118. /* Create and define a buffer */
  1119. (*GenBuffersARB)(1, &bufferID);
  1120. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, bufferID);
  1121. (*BufferDataARB)(GL_ARRAY_BUFFER_ARB, BUFFER_DATA_SIZE, data,
  1122. GL_DYNAMIC_DRAW_ARB);
  1123. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1124. /* If we're using MapBufferRange, and if the BufferParameteriAPPLE
  1125. * function is present, use it before mapping. This particular
  1126. * use is a no-op, intended just to exercise the entry point.
  1127. */
  1128. if (usage == Use_Map_Buffer_Range && BufferParameteriAPPLE != NULL) {
  1129. (*BufferParameteriAPPLE)(GL_ARRAY_BUFFER_ARB,
  1130. GL_BUFFER_SERIALIZED_MODIFY_APPLE, GL_TRUE);
  1131. }
  1132. /* Map it, and make sure it's mapped. */
  1133. switch(usage) {
  1134. case Use_Map_Buffer:
  1135. dataPtr = (float *) (*MapBufferARB)(
  1136. GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
  1137. break;
  1138. case Use_Map_Buffer_Range:
  1139. dataPtr = (float *)(*MapBufferRange)(GL_ARRAY_BUFFER_ARB,
  1140. 4, 16, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
  1141. break;
  1142. }
  1143. if (dataPtr == NULL) {
  1144. fprintf(stderr, "%s: %s returned NULL\n", __FUNCTION__,
  1145. usage == Use_Map_Buffer ? "MapBuffer" : "MapBufferRange");
  1146. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1147. (*DeleteBuffersARB)(1, &bufferID);
  1148. return GL_FALSE;
  1149. }
  1150. (*GetBufferParameterivARB)(GL_ARRAY_BUFFER_ARB, GL_BUFFER_MAPPED_ARB,
  1151. &bufferMapped);
  1152. if (!bufferMapped) {
  1153. fprintf(stderr, "%s: buffer should be mapped but isn't\n", __FUNCTION__);
  1154. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1155. (*DeleteBuffersARB)(1, &bufferID);
  1156. return GL_FALSE;
  1157. }
  1158. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1159. /* Write something to it, just to make sure we don't segfault. */
  1160. *dataPtr = 1.5;
  1161. /* Unmap to show we're finished with the buffer. Note that if we're
  1162. * using MapBufferRange, we first have to flush the range we modified.
  1163. */
  1164. if (usage == Use_Map_Buffer_Range) {
  1165. (*FlushMappedBufferRange)(GL_ARRAY_BUFFER_ARB, 4, 16);
  1166. }
  1167. if (!(*UnmapBufferARB)(GL_ARRAY_BUFFER_ARB)) {
  1168. fprintf(stderr, "%s: UnmapBuffer failed\n", __FUNCTION__);
  1169. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1170. (*DeleteBuffersARB)(1, &bufferID);
  1171. return GL_FALSE;
  1172. }
  1173. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1174. /* All done. */
  1175. (*BindBufferARB)(GL_ARRAY_BUFFER_ARB, 0);
  1176. (*DeleteBuffersARB)(1, &bufferID);
  1177. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1178. return GL_TRUE;
  1179. #undef BUFFER_DATA_SIZE
  1180. }
  1181. /**************************************************************************
  1182. * Exercises for occlusion query
  1183. */
  1184. static GLboolean
  1185. exercise_occlusion_query(void)
  1186. {
  1187. GLuint queryObject;
  1188. GLint queryReady;
  1189. GLuint querySampleCount;
  1190. GLint queryCurrent;
  1191. GLint queryCounterBits;
  1192. /* Get the function pointers we need. These are from
  1193. * GL_ARB_vertex_buffer_object and are required in all
  1194. * cases.
  1195. */
  1196. DECLARE_GLFUNC_PTR(GenQueriesARB, PFNGLGENQUERIESARBPROC);
  1197. DECLARE_GLFUNC_PTR(BeginQueryARB, PFNGLBEGINQUERYARBPROC);
  1198. DECLARE_GLFUNC_PTR(GetQueryivARB, PFNGLGETQUERYIVARBPROC);
  1199. DECLARE_GLFUNC_PTR(EndQueryARB, PFNGLENDQUERYARBPROC);
  1200. DECLARE_GLFUNC_PTR(IsQueryARB, PFNGLISQUERYARBPROC);
  1201. DECLARE_GLFUNC_PTR(GetQueryObjectivARB, PFNGLGETQUERYOBJECTIVARBPROC);
  1202. DECLARE_GLFUNC_PTR(GetQueryObjectuivARB, PFNGLGETQUERYOBJECTUIVARBPROC);
  1203. DECLARE_GLFUNC_PTR(DeleteQueriesARB, PFNGLDELETEQUERIESARBPROC);
  1204. /* Make sure we have all the function pointers we need. */
  1205. if (GenQueriesARB == NULL ||
  1206. BeginQueryARB == NULL ||
  1207. GetQueryivARB == NULL ||
  1208. EndQueryARB == NULL ||
  1209. IsQueryARB == NULL ||
  1210. GetQueryObjectivARB == NULL ||
  1211. GetQueryObjectuivARB == NULL ||
  1212. DeleteQueriesARB == NULL) {
  1213. fprintf(stderr, "%s: don't have all the Query functions\n", __FUNCTION__);
  1214. return GL_FALSE;
  1215. }
  1216. /* Create a query object, and start a query. */
  1217. (*GenQueriesARB)(1, &queryObject);
  1218. (*BeginQueryARB)(GL_SAMPLES_PASSED_ARB, queryObject);
  1219. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1220. /* While we're in the query, check the functions that are supposed
  1221. * to return which query we're in and how many bits of resolution
  1222. * we get.
  1223. */
  1224. (*GetQueryivARB)(GL_SAMPLES_PASSED_ARB, GL_CURRENT_QUERY_ARB, &queryCurrent);
  1225. if (queryCurrent != queryObject) {
  1226. fprintf(stderr, "%s: current query 0x%x != set query 0x%x\n",
  1227. __FUNCTION__, queryCurrent, queryObject);
  1228. (*EndQueryARB)(GL_SAMPLES_PASSED_ARB);
  1229. (*DeleteQueriesARB)(1, &queryObject);
  1230. return GL_FALSE;
  1231. }
  1232. (*GetQueryivARB)(GL_SAMPLES_PASSED_ARB, GL_QUERY_COUNTER_BITS_ARB,
  1233. &queryCounterBits);
  1234. if (queryCounterBits < 1) {
  1235. fprintf(stderr, "%s: query counter bits is too small (%d)\n",
  1236. __FUNCTION__, queryCounterBits);
  1237. (*EndQueryARB)(GL_SAMPLES_PASSED_ARB);
  1238. (*DeleteQueriesARB)(1, &queryObject);
  1239. return GL_FALSE;
  1240. }
  1241. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1242. /* Finish up the query. Since we didn't draw anything, the result
  1243. * should be 0 passed samples.
  1244. */
  1245. (*EndQueryARB)(GL_SAMPLES_PASSED_ARB);
  1246. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1247. /* Routine existence test */
  1248. if (!(*IsQueryARB)(queryObject)) {
  1249. fprintf(stderr, "%s: query object 0x%x fails existence test\n",
  1250. __FUNCTION__, queryObject);
  1251. (*DeleteQueriesARB)(1, &queryObject);
  1252. return GL_FALSE;
  1253. }
  1254. /* Loop until the query is ready, then get back the result. We use
  1255. * the signed query for the boolean value of whether the result is
  1256. * available, but the unsigned query to actually pull the result;
  1257. * this is just to test both entrypoints, but in a real query you may
  1258. * need the extra bit of resolution.
  1259. */
  1260. queryReady = GL_FALSE;
  1261. do {
  1262. (*GetQueryObjectivARB)(queryObject, GL_QUERY_RESULT_AVAILABLE_ARB,
  1263. &queryReady);
  1264. } while (!queryReady);
  1265. (*GetQueryObjectuivARB)(queryObject, GL_QUERY_RESULT_ARB, &querySampleCount);
  1266. (*DeleteQueriesARB)(1, &queryObject);
  1267. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1268. /* If sample count isn't 0, something's funny. */
  1269. if (querySampleCount > 0) {
  1270. fprintf(stderr, "%s: expected query result of 0, got %ud\n",
  1271. __FUNCTION__, querySampleCount);
  1272. return GL_FALSE;
  1273. }
  1274. /* Here, all is well. */
  1275. return GL_TRUE;
  1276. }
  1277. /**************************************************************************
  1278. * The following functions are used to check that the named OpenGL function
  1279. * actually does what it's supposed to do.
  1280. * The naming of these functions is significant. The getprocaddress.py script
  1281. * scans this file and extracts these function names.
  1282. */
  1283. static GLboolean
  1284. test_WeightPointerARB(generic_func func)
  1285. {
  1286. /* Assume we have at least 2 vertex units (or this extension makes
  1287. * no sense), and establish a set of 2-element vector weights.
  1288. * We use floats that can be represented exactly in binary
  1289. * floating point formats so we can compare correctly later.
  1290. * We also make sure the 0th entry matches the default weights,
  1291. * so we can restore the default easily.
  1292. */
  1293. #define USE_VERTEX_UNITS 2
  1294. #define USE_WEIGHT_INDEX 3
  1295. static GLfloat weights[] = {
  1296. 1.0, 0.0,
  1297. 0.875, 0.125,
  1298. 0.75, 0.25,
  1299. 0.625, 0.375,
  1300. 0.5, 0.5,
  1301. 0.375, 0.625,
  1302. 0.25, 0.75,
  1303. 0.125, 0.875,
  1304. 0.0, 1.0,
  1305. };
  1306. GLint numVertexUnits;
  1307. GLfloat *currentWeights;
  1308. int i;
  1309. int errorCount = 0;
  1310. PFNGLWEIGHTPOINTERARBPROC WeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC) func;
  1311. /* Make sure we have at least two vertex units */
  1312. glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &numVertexUnits);
  1313. if (numVertexUnits < USE_VERTEX_UNITS) {
  1314. fprintf(stderr, "%s: need %d vertex units, got %d\n",
  1315. __FUNCTION__, USE_VERTEX_UNITS, numVertexUnits);
  1316. return GL_FALSE;
  1317. }
  1318. /* Make sure we allocate enough room to query all the current weights */
  1319. currentWeights = (GLfloat *)malloc(numVertexUnits * sizeof(GLfloat));
  1320. if (currentWeights == NULL) {
  1321. fprintf(stderr, "%s: couldn't allocate room for %d floats\n",
  1322. __FUNCTION__, numVertexUnits);
  1323. return GL_FALSE;
  1324. }
  1325. /* Set up the pointer, enable the state, and try to send down a
  1326. * weight vector (we'll arbitrarily send index 2).
  1327. */
  1328. (*WeightPointerARB)(USE_VERTEX_UNITS, GL_FLOAT, 0, weights);
  1329. glEnableClientState(GL_WEIGHT_ARRAY_ARB);
  1330. glArrayElement(USE_WEIGHT_INDEX);
  1331. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1332. /* Verify that it changed the current state. */
  1333. glGetFloatv(GL_CURRENT_WEIGHT_ARB, currentWeights);
  1334. for (i = 0; i < numVertexUnits; i++) {
  1335. if (i < USE_VERTEX_UNITS) {
  1336. /* This is one of the units we explicitly set. */
  1337. if (currentWeights[i] != weights[USE_VERTEX_UNITS*USE_WEIGHT_INDEX + i]) {
  1338. fprintf(stderr, "%s: current weight at index %d is %f, should be %f\n",
  1339. __FUNCTION__, i, currentWeights[i],
  1340. weights[USE_VERTEX_UNITS*USE_WEIGHT_INDEX + i]);
  1341. errorCount++;
  1342. }
  1343. }
  1344. else {
  1345. /* All other weights should be 0. */
  1346. if (currentWeights[i] != 0.0) {
  1347. fprintf(stderr, "%s: current weight at index %d is %f, should be %f\n",
  1348. __FUNCTION__, i, 0.0,
  1349. weights[USE_VERTEX_UNITS*USE_WEIGHT_INDEX + i]);
  1350. errorCount++;
  1351. }
  1352. }
  1353. }
  1354. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1355. /* Restore the old state. We know the default set of weights is in
  1356. * index 0.
  1357. */
  1358. glArrayElement(0);
  1359. glDisableClientState(GL_WEIGHT_ARRAY_ARB);
  1360. (*WeightPointerARB)(0, GL_FLOAT, 0, NULL);
  1361. free(currentWeights);
  1362. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1363. /* We're fine if we didn't get any mismatches. */
  1364. if (errorCount == 0) {
  1365. return GL_TRUE;
  1366. }
  1367. else {
  1368. return GL_FALSE;
  1369. }
  1370. }
  1371. /* Wrappers on the exercise_occlusion_query function */
  1372. static GLboolean
  1373. test_GenQueriesARB(generic_func func)
  1374. {
  1375. (void) func;
  1376. return exercise_occlusion_query();
  1377. }
  1378. static GLboolean
  1379. test_BeginQueryARB(generic_func func)
  1380. {
  1381. (void) func;
  1382. return exercise_occlusion_query();
  1383. }
  1384. static GLboolean
  1385. test_GetQueryivARB(generic_func func)
  1386. {
  1387. (void) func;
  1388. return exercise_occlusion_query();
  1389. }
  1390. static GLboolean
  1391. test_EndQueryARB(generic_func func)
  1392. {
  1393. (void) func;
  1394. return exercise_occlusion_query();
  1395. }
  1396. static GLboolean
  1397. test_IsQueryARB(generic_func func)
  1398. {
  1399. (void) func;
  1400. return exercise_occlusion_query();
  1401. }
  1402. static GLboolean
  1403. test_GetQueryObjectivARB(generic_func func)
  1404. {
  1405. (void) func;
  1406. return exercise_occlusion_query();
  1407. }
  1408. static GLboolean
  1409. test_GetQueryObjectuivARB(generic_func func)
  1410. {
  1411. (void) func;
  1412. return exercise_occlusion_query();
  1413. }
  1414. static GLboolean
  1415. test_DeleteQueriesARB(generic_func func)
  1416. {
  1417. (void) func;
  1418. return exercise_occlusion_query();
  1419. }
  1420. /* Wrappers on the exercise_buffer_objects() function */
  1421. static GLboolean
  1422. test_GenBuffersARB(generic_func func)
  1423. {
  1424. (void) func;
  1425. return exercise_buffer_objects(Use_Map_Buffer);
  1426. }
  1427. static GLboolean
  1428. test_BindBufferARB(generic_func func)
  1429. {
  1430. (void) func;
  1431. return exercise_buffer_objects(Use_Map_Buffer);
  1432. }
  1433. static GLboolean
  1434. test_BufferDataARB(generic_func func)
  1435. {
  1436. (void) func;
  1437. return exercise_buffer_objects(Use_Map_Buffer);
  1438. }
  1439. static GLboolean
  1440. test_MapBufferARB(generic_func func)
  1441. {
  1442. (void) func;
  1443. return exercise_buffer_objects(Use_Map_Buffer);
  1444. }
  1445. static GLboolean
  1446. test_UnmapBufferARB(generic_func func)
  1447. {
  1448. (void) func;
  1449. return exercise_buffer_objects(Use_Map_Buffer);
  1450. }
  1451. static GLboolean
  1452. test_DeleteBuffersARB(generic_func func)
  1453. {
  1454. (void) func;
  1455. return exercise_buffer_objects(Use_Map_Buffer);
  1456. }
  1457. static GLboolean
  1458. test_GetBufferParameterivARB(generic_func func)
  1459. {
  1460. (void) func;
  1461. return exercise_buffer_objects(Use_Map_Buffer);
  1462. }
  1463. static GLboolean
  1464. test_FlushMappedBufferRange(generic_func func)
  1465. {
  1466. (void) func;
  1467. return exercise_buffer_objects(Use_Map_Buffer_Range);
  1468. }
  1469. static GLboolean
  1470. test_MapBufferRange(generic_func func)
  1471. {
  1472. (void) func;
  1473. return exercise_buffer_objects(Use_Map_Buffer_Range);
  1474. }
  1475. static GLboolean
  1476. test_BufferParameteriAPPLE(generic_func func)
  1477. {
  1478. (void) func;
  1479. return exercise_buffer_objects(Use_Map_Buffer_Range);
  1480. }
  1481. /* Wrappers on the exercise_framebuffer() function */
  1482. static GLboolean
  1483. test_BindFramebufferEXT(generic_func func)
  1484. {
  1485. (void) func;
  1486. return exercise_framebuffer();
  1487. }
  1488. static GLboolean
  1489. test_BindRenderbufferEXT(generic_func func)
  1490. {
  1491. (void) func;
  1492. return exercise_framebuffer();
  1493. }
  1494. static GLboolean
  1495. test_CheckFramebufferStatusEXT(generic_func func)
  1496. {
  1497. (void) func;
  1498. return exercise_framebuffer();
  1499. }
  1500. static GLboolean
  1501. test_DeleteFramebuffersEXT(generic_func func)
  1502. {
  1503. (void) func;
  1504. return exercise_framebuffer();
  1505. }
  1506. static GLboolean
  1507. test_DeleteRenderbuffersEXT(generic_func func)
  1508. {
  1509. (void) func;
  1510. return exercise_framebuffer();
  1511. }
  1512. static GLboolean
  1513. test_FramebufferRenderbufferEXT(generic_func func)
  1514. {
  1515. (void) func;
  1516. return exercise_framebuffer();
  1517. }
  1518. static GLboolean
  1519. test_GenFramebuffersEXT(generic_func func)
  1520. {
  1521. (void) func;
  1522. return exercise_framebuffer();
  1523. }
  1524. static GLboolean
  1525. test_GenRenderbuffersEXT(generic_func func)
  1526. {
  1527. (void) func;
  1528. return exercise_framebuffer();
  1529. }
  1530. static GLboolean
  1531. test_IsFramebufferEXT(generic_func func)
  1532. {
  1533. (void) func;
  1534. return exercise_framebuffer();
  1535. }
  1536. static GLboolean
  1537. test_IsRenderbufferEXT(generic_func func)
  1538. {
  1539. (void) func;
  1540. return exercise_framebuffer();
  1541. }
  1542. static GLboolean
  1543. test_RenderbufferStorageEXT(generic_func func)
  1544. {
  1545. (void) func;
  1546. return exercise_framebuffer();
  1547. }
  1548. static GLboolean
  1549. test_BlitFramebufferEXT(generic_func func)
  1550. {
  1551. (void) func;
  1552. return exercise_framebuffer();
  1553. }
  1554. /* These are wrappers on the exercise_CompressedTextures function.
  1555. * Unfortunately, we cannot test the 1D counterparts, because the
  1556. * texture compressions available all support 2D and higher only.
  1557. */
  1558. static GLboolean
  1559. test_CompressedTexImage2DARB(generic_func func)
  1560. {
  1561. (void) func;
  1562. return exercise_CompressedTextures(GL_TEXTURE_2D);
  1563. }
  1564. static GLboolean
  1565. test_CompressedTexSubImage2DARB(generic_func func)
  1566. {
  1567. (void) func;
  1568. return exercise_CompressedTextures(GL_TEXTURE_2D);
  1569. }
  1570. static GLboolean
  1571. test_CompressedTexImage3DARB(generic_func func)
  1572. {
  1573. (void) func;
  1574. return exercise_CompressedTextures(GL_TEXTURE_3D);
  1575. }
  1576. static GLboolean
  1577. test_CompressedTexSubImage3DARB(generic_func func)
  1578. {
  1579. (void) func;
  1580. return exercise_CompressedTextures(GL_TEXTURE_3D);
  1581. }
  1582. static GLboolean
  1583. test_GetCompressedTexImageARB(generic_func func)
  1584. {
  1585. (void) func;
  1586. return exercise_CompressedTextures(GL_TEXTURE_3D);
  1587. }
  1588. /* Wrappers on exercise_fences(). */
  1589. static GLboolean
  1590. test_DeleteFencesNV(generic_func func)
  1591. {
  1592. (void) func;
  1593. return exercise_fences();
  1594. }
  1595. static GLboolean
  1596. test_GenFencesNV(generic_func func)
  1597. {
  1598. (void) func;
  1599. return exercise_fences();
  1600. }
  1601. static GLboolean
  1602. test_SetFenceNV(generic_func func)
  1603. {
  1604. (void) func;
  1605. return exercise_fences();
  1606. }
  1607. static GLboolean
  1608. test_TestFenceNV(generic_func func)
  1609. {
  1610. (void) func;
  1611. return exercise_fences();
  1612. }
  1613. static GLboolean
  1614. test_FinishFenceNV(generic_func func)
  1615. {
  1616. (void) func;
  1617. return exercise_fences();
  1618. }
  1619. static GLboolean
  1620. test_GetFenceivNV(generic_func func)
  1621. {
  1622. (void) func;
  1623. return exercise_fences();
  1624. }
  1625. static GLboolean
  1626. test_IsFenceNV(generic_func func)
  1627. {
  1628. (void) func;
  1629. return exercise_fences();
  1630. }
  1631. /* A bunch of glUniform*() tests */
  1632. static GLboolean
  1633. test_Uniform1iv(generic_func func)
  1634. {
  1635. PFNGLUNIFORM1IVARBPROC Uniform1ivARB = (PFNGLUNIFORM1IVARBPROC) func;
  1636. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1637. /* This is a trivial fragment shader that sets the color of the
  1638. * fragment to the uniform value passed in.
  1639. */
  1640. static const char *fragmentShaderText =
  1641. "uniform int uniformColor;"
  1642. "void main() {gl_FragColor.r = uniformColor;}";
  1643. static const char *uniformName = "uniformColor";
  1644. GLhandleARB program;
  1645. GLint uniformLocation;
  1646. const GLint uniform[1] = {1};
  1647. GLint queriedUniform[1];
  1648. if (GetUniformivARB == NULL) {
  1649. return GL_FALSE;
  1650. }
  1651. /* Call a helper function to compile up the shader and give
  1652. * us back the validated program and uniform location.
  1653. * If it fails, something's wrong and we can't continue.
  1654. */
  1655. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1656. &program, &uniformLocation)) {
  1657. return GL_FALSE;
  1658. }
  1659. /* Set the value of the program uniform. Note that you must
  1660. * use a compatible type. Our uniform above is an integer
  1661. * so we must set it using integer versions
  1662. * of the Uniform* functions. The "1" means we're setting
  1663. * one vector's worth of information.
  1664. */
  1665. (*Uniform1ivARB)(uniformLocation, 1, uniform);
  1666. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1667. /* Query it back */
  1668. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1669. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1670. /* Clean up before we check to see whether it came back unscathed */
  1671. exercise_uniform_end(program);
  1672. /* Now check to see whether the uniform came back as expected. This
  1673. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1674. */
  1675. return compare_ints(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1676. }
  1677. static GLboolean
  1678. test_Uniform1i(generic_func func)
  1679. {
  1680. PFNGLUNIFORM1IARBPROC Uniform1iARB = (PFNGLUNIFORM1IARBPROC) func;
  1681. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1682. /* This is a trivial fragment shader that sets the color of the
  1683. * fragment to the uniform value passed in.
  1684. */
  1685. static const char *fragmentShaderText =
  1686. "uniform int uniformColor;"
  1687. "void main() {gl_FragColor.r = uniformColor;}";
  1688. static const char *uniformName = "uniformColor";
  1689. GLhandleARB program;
  1690. GLint uniformLocation;
  1691. const GLint uniform[1] = {1};
  1692. GLint queriedUniform[4];
  1693. if (GetUniformivARB == NULL) {
  1694. return GL_FALSE;
  1695. }
  1696. /* Call a helper function to compile up the shader and give
  1697. * us back the validated program and uniform location.
  1698. * If it fails, something's wrong and we can't continue.
  1699. */
  1700. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1701. &program, &uniformLocation)) {
  1702. return GL_FALSE;
  1703. }
  1704. /* Set the value of the program uniform. Note that you must
  1705. * use a compatible type. Our uniform above is an integer
  1706. * so we must set it using integer versions
  1707. * of the Uniform* functions.
  1708. */
  1709. (*Uniform1iARB)(uniformLocation, uniform[0]);
  1710. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1711. /* Query it back */
  1712. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1713. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1714. /* Clean up before we check to see whether it came back unscathed */
  1715. exercise_uniform_end(program);
  1716. /* Now check to see whether the uniform came back as expected. This
  1717. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1718. */
  1719. return compare_ints(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1720. }
  1721. static GLboolean
  1722. test_Uniform1fv(generic_func func)
  1723. {
  1724. PFNGLUNIFORM1FVARBPROC Uniform1fvARB = (PFNGLUNIFORM1FVARBPROC) func;
  1725. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1726. /* This is a trivial fragment shader that sets the color of the
  1727. * fragment to the uniform value passed in.
  1728. */
  1729. static const char *fragmentShaderText =
  1730. "uniform float uniformColor;"
  1731. "void main() {gl_FragColor.r = uniformColor;}";
  1732. static const char *uniformName = "uniformColor";
  1733. GLhandleARB program;
  1734. GLint uniformLocation;
  1735. const GLfloat uniform[1] = {1.1};
  1736. GLfloat queriedUniform[1];
  1737. if (GetUniformfvARB == NULL) {
  1738. return GL_FALSE;
  1739. }
  1740. /* Call a helper function to compile up the shader and give
  1741. * us back the validated program and uniform location.
  1742. * If it fails, something's wrong and we can't continue.
  1743. */
  1744. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1745. &program, &uniformLocation)) {
  1746. return GL_FALSE;
  1747. }
  1748. /* Set the value of the program uniform. Note that you must
  1749. * use a compatible type. Our uniform above is a float
  1750. * so we must set it using float versions
  1751. * of the Uniform* functions. The "1" means we're setting
  1752. * one vector's worth of information.
  1753. */
  1754. (*Uniform1fvARB)(uniformLocation, 1, uniform);
  1755. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1756. /* Query it back */
  1757. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1758. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1759. /* Clean up before we check to see whether it came back unscathed */
  1760. exercise_uniform_end(program);
  1761. /* Now check to see whether the uniform came back as expected. This
  1762. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1763. */
  1764. return compare_floats(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1765. }
  1766. static GLboolean
  1767. test_Uniform1f(generic_func func)
  1768. {
  1769. PFNGLUNIFORM1FARBPROC Uniform1fARB = (PFNGLUNIFORM1FARBPROC) func;
  1770. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1771. /* This is a trivial fragment shader that sets the color of the
  1772. * fragment to the uniform value passed in.
  1773. */
  1774. static const char *fragmentShaderText =
  1775. "uniform float uniformColor;"
  1776. "void main() {gl_FragColor.r = uniformColor;}";
  1777. static const char *uniformName = "uniformColor";
  1778. GLhandleARB program;
  1779. GLint uniformLocation;
  1780. const GLfloat uniform[1] = {1.1};
  1781. GLfloat queriedUniform[1];
  1782. if (GetUniformfvARB == NULL) {
  1783. return GL_FALSE;
  1784. }
  1785. /* Call a helper function to compile up the shader and give
  1786. * us back the validated program and uniform location.
  1787. * If it fails, something's wrong and we can't continue.
  1788. */
  1789. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1790. &program, &uniformLocation)) {
  1791. return GL_FALSE;
  1792. }
  1793. /* Set the value of the program uniform. Note that you must
  1794. * use a compatible type. Our uniform above is a float
  1795. * so we must set it using float versions
  1796. * of the Uniform* functions.
  1797. */
  1798. (*Uniform1fARB)(uniformLocation, uniform[0]);
  1799. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1800. /* Query it back */
  1801. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1802. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1803. /* Clean up before we check to see whether it came back unscathed */
  1804. exercise_uniform_end(program);
  1805. /* Now check to see whether the uniform came back as expected. This
  1806. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1807. */
  1808. return compare_floats(__FUNCTION__, 1, uniform, 1, queriedUniform);
  1809. }
  1810. static GLboolean
  1811. test_Uniform2iv(generic_func func)
  1812. {
  1813. PFNGLUNIFORM2IVARBPROC Uniform2ivARB = (PFNGLUNIFORM2IVARBPROC) func;
  1814. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1815. /* This is a trivial fragment shader that sets the color of the
  1816. * fragment to the uniform value passed in.
  1817. */
  1818. static const char *fragmentShaderText =
  1819. "uniform ivec2 uniformColor;"
  1820. "void main() {gl_FragColor.rg = uniformColor;}";
  1821. static const char *uniformName = "uniformColor";
  1822. GLhandleARB program;
  1823. GLint uniformLocation;
  1824. const GLint uniform[2] = {1,2};
  1825. GLint queriedUniform[2];
  1826. if (GetUniformivARB == NULL) {
  1827. return GL_FALSE;
  1828. }
  1829. /* Call a helper function to compile up the shader and give
  1830. * us back the validated program and uniform location.
  1831. * If it fails, something's wrong and we can't continue.
  1832. */
  1833. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1834. &program, &uniformLocation)) {
  1835. return GL_FALSE;
  1836. }
  1837. /* Set the value of the program uniform. Note that you must
  1838. * use a compatible type. Our uniform above is an integer
  1839. * vector 2 (ivec2), so we must set it using integer versions
  1840. * of the Uniform* functions. The "1" means we're setting
  1841. * one vector's worth of information.
  1842. */
  1843. (*Uniform2ivARB)(uniformLocation, 1, uniform);
  1844. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1845. /* Query it back */
  1846. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1847. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1848. /* Clean up before we check to see whether it came back unscathed */
  1849. exercise_uniform_end(program);
  1850. /* Now check to see whether the uniform came back as expected. This
  1851. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1852. */
  1853. return compare_ints(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1854. }
  1855. static GLboolean
  1856. test_Uniform2i(generic_func func)
  1857. {
  1858. PFNGLUNIFORM2IARBPROC Uniform2iARB = (PFNGLUNIFORM2IARBPROC) func;
  1859. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1860. /* This is a trivial fragment shader that sets the color of the
  1861. * fragment to the uniform value passed in.
  1862. */
  1863. static const char *fragmentShaderText =
  1864. "uniform ivec2 uniformColor;"
  1865. "void main() {gl_FragColor.rg = uniformColor;}";
  1866. static const char *uniformName = "uniformColor";
  1867. GLhandleARB program;
  1868. GLint uniformLocation;
  1869. const GLint uniform[2] = {1,2};
  1870. GLint queriedUniform[4];
  1871. if (GetUniformivARB == NULL) {
  1872. return GL_FALSE;
  1873. }
  1874. /* Call a helper function to compile up the shader and give
  1875. * us back the validated program and uniform location.
  1876. * If it fails, something's wrong and we can't continue.
  1877. */
  1878. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1879. &program, &uniformLocation)) {
  1880. return GL_FALSE;
  1881. }
  1882. /* Set the value of the program uniform. Note that you must
  1883. * use a compatible type. Our uniform above is an integer
  1884. * vector 2 (ivec2), so we must set it using integer versions
  1885. * of the Uniform* functions.
  1886. */
  1887. (*Uniform2iARB)(uniformLocation, uniform[0], uniform[1]);
  1888. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1889. /* Query it back */
  1890. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  1891. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1892. /* Clean up before we check to see whether it came back unscathed */
  1893. exercise_uniform_end(program);
  1894. /* Now check to see whether the uniform came back as expected. This
  1895. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1896. */
  1897. return compare_ints(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1898. }
  1899. static GLboolean
  1900. test_Uniform2fv(generic_func func)
  1901. {
  1902. PFNGLUNIFORM2FVARBPROC Uniform2fvARB = (PFNGLUNIFORM2FVARBPROC) func;
  1903. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1904. /* This is a trivial fragment shader that sets the color of the
  1905. * fragment to the uniform value passed in.
  1906. */
  1907. static const char *fragmentShaderText =
  1908. "uniform vec2 uniformColor;"
  1909. "void main() {gl_FragColor.rg = uniformColor;}";
  1910. static const char *uniformName = "uniformColor";
  1911. GLhandleARB program;
  1912. GLint uniformLocation;
  1913. const GLfloat uniform[2] = {1.1,2.2};
  1914. GLfloat queriedUniform[2];
  1915. if (GetUniformfvARB == NULL) {
  1916. return GL_FALSE;
  1917. }
  1918. /* Call a helper function to compile up the shader and give
  1919. * us back the validated program and uniform location.
  1920. * If it fails, something's wrong and we can't continue.
  1921. */
  1922. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1923. &program, &uniformLocation)) {
  1924. return GL_FALSE;
  1925. }
  1926. /* Set the value of the program uniform. Note that you must
  1927. * use a compatible type. Our uniform above is a float
  1928. * vector 2 (vec2), so we must set it using float versions
  1929. * of the Uniform* functions. The "1" means we're setting
  1930. * one vector's worth of information.
  1931. */
  1932. (*Uniform2fvARB)(uniformLocation, 1, uniform);
  1933. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1934. /* Query it back */
  1935. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1936. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1937. /* Clean up before we check to see whether it came back unscathed */
  1938. exercise_uniform_end(program);
  1939. /* Now check to see whether the uniform came back as expected. This
  1940. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1941. */
  1942. return compare_floats(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1943. }
  1944. static GLboolean
  1945. test_Uniform2f(generic_func func)
  1946. {
  1947. PFNGLUNIFORM2FARBPROC Uniform2fARB = (PFNGLUNIFORM2FARBPROC) func;
  1948. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  1949. /* This is a trivial fragment shader that sets the color of the
  1950. * fragment to the uniform value passed in.
  1951. */
  1952. static const char *fragmentShaderText =
  1953. "uniform vec2 uniformColor;"
  1954. "void main() {gl_FragColor.rg = uniformColor;}";
  1955. static const char *uniformName = "uniformColor";
  1956. GLhandleARB program;
  1957. GLint uniformLocation;
  1958. const GLfloat uniform[2] = {1.1,2.2};
  1959. GLfloat queriedUniform[2];
  1960. if (GetUniformfvARB == NULL) {
  1961. return GL_FALSE;
  1962. }
  1963. /* Call a helper function to compile up the shader and give
  1964. * us back the validated program and uniform location.
  1965. * If it fails, something's wrong and we can't continue.
  1966. */
  1967. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  1968. &program, &uniformLocation)) {
  1969. return GL_FALSE;
  1970. }
  1971. /* Set the value of the program uniform. Note that you must
  1972. * use a compatible type. Our uniform above is a float
  1973. * vector 2 (vec2), so we must set it using float versions
  1974. * of the Uniform* functions.
  1975. */
  1976. (*Uniform2fARB)(uniformLocation, uniform[0], uniform[1]);
  1977. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1978. /* Query it back */
  1979. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  1980. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  1981. /* Clean up before we check to see whether it came back unscathed */
  1982. exercise_uniform_end(program);
  1983. /* Now check to see whether the uniform came back as expected. This
  1984. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  1985. */
  1986. return compare_floats(__FUNCTION__, 2, uniform, 2, queriedUniform);
  1987. }
  1988. static GLboolean
  1989. test_Uniform3iv(generic_func func)
  1990. {
  1991. PFNGLUNIFORM3IVARBPROC Uniform3ivARB = (PFNGLUNIFORM3IVARBPROC) func;
  1992. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  1993. /* This is a trivial fragment shader that sets the color of the
  1994. * fragment to the uniform value passed in.
  1995. */
  1996. static const char *fragmentShaderText =
  1997. "uniform ivec3 uniformColor;"
  1998. "void main() {gl_FragColor.rgb = uniformColor;}";
  1999. static const char *uniformName = "uniformColor";
  2000. GLhandleARB program;
  2001. GLint uniformLocation;
  2002. const GLint uniform[3] = {1,2,3};
  2003. GLint queriedUniform[3];
  2004. if (GetUniformivARB == NULL) {
  2005. return GL_FALSE;
  2006. }
  2007. /* Call a helper function to compile up the shader and give
  2008. * us back the validated program and uniform location.
  2009. * If it fails, something's wrong and we can't continue.
  2010. */
  2011. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2012. &program, &uniformLocation)) {
  2013. return GL_FALSE;
  2014. }
  2015. /* Set the value of the program uniform. Note that you must
  2016. * use a compatible type. Our uniform above is an integer
  2017. * vector 3 (ivec3), so we must set it using integer versions
  2018. * of the Uniform* functions. The "1" means we're setting
  2019. * one vector's worth of information.
  2020. */
  2021. (*Uniform3ivARB)(uniformLocation, 1, uniform);
  2022. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2023. /* Query it back */
  2024. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2025. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2026. /* Clean up before we check to see whether it came back unscathed */
  2027. exercise_uniform_end(program);
  2028. /* Now check to see whether the uniform came back as expected. This
  2029. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2030. */
  2031. return compare_ints(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2032. }
  2033. static GLboolean
  2034. test_Uniform3i(generic_func func)
  2035. {
  2036. PFNGLUNIFORM3IARBPROC Uniform3iARB = (PFNGLUNIFORM3IARBPROC) func;
  2037. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  2038. /* This is a trivial fragment shader that sets the color of the
  2039. * fragment to the uniform value passed in.
  2040. */
  2041. static const char *fragmentShaderText =
  2042. "uniform ivec3 uniformColor;"
  2043. "void main() {gl_FragColor.rgb = uniformColor;}";
  2044. static const char *uniformName = "uniformColor";
  2045. GLhandleARB program;
  2046. GLint uniformLocation;
  2047. const GLint uniform[3] = {1,2,3};
  2048. GLint queriedUniform[4];
  2049. if (GetUniformivARB == NULL) {
  2050. return GL_FALSE;
  2051. }
  2052. /* Call a helper function to compile up the shader and give
  2053. * us back the validated program and uniform location.
  2054. * If it fails, something's wrong and we can't continue.
  2055. */
  2056. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2057. &program, &uniformLocation)) {
  2058. return GL_FALSE;
  2059. }
  2060. /* Set the value of the program uniform. Note that you must
  2061. * use a compatible type. Our uniform above is an integer
  2062. * vector 3 (ivec3), so we must set it using integer versions
  2063. * of the Uniform* functions.
  2064. */
  2065. (*Uniform3iARB)(uniformLocation, uniform[0], uniform[1], uniform[2]);
  2066. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2067. /* Query it back */
  2068. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2069. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2070. /* Clean up before we check to see whether it came back unscathed */
  2071. exercise_uniform_end(program);
  2072. /* Now check to see whether the uniform came back as expected. This
  2073. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2074. */
  2075. return compare_ints(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2076. }
  2077. static GLboolean
  2078. test_Uniform3fv(generic_func func)
  2079. {
  2080. PFNGLUNIFORM3FVARBPROC Uniform3fvARB = (PFNGLUNIFORM3FVARBPROC) func;
  2081. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2082. /* This is a trivial fragment shader that sets the color of the
  2083. * fragment to the uniform value passed in.
  2084. */
  2085. static const char *fragmentShaderText =
  2086. "uniform vec3 uniformColor;"
  2087. "void main() {gl_FragColor.rgb = uniformColor;}";
  2088. static const char *uniformName = "uniformColor";
  2089. GLhandleARB program;
  2090. GLint uniformLocation;
  2091. const GLfloat uniform[3] = {1.1,2.2,3.3};
  2092. GLfloat queriedUniform[3];
  2093. if (GetUniformfvARB == NULL) {
  2094. return GL_FALSE;
  2095. }
  2096. /* Call a helper function to compile up the shader and give
  2097. * us back the validated program and uniform location.
  2098. * If it fails, something's wrong and we can't continue.
  2099. */
  2100. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2101. &program, &uniformLocation)) {
  2102. return GL_FALSE;
  2103. }
  2104. /* Set the value of the program uniform. Note that you must
  2105. * use a compatible type. Our uniform above is a float
  2106. * vector 3 (vec3), so we must set it using float versions
  2107. * of the Uniform* functions. The "1" means we're setting
  2108. * one vector's worth of information.
  2109. */
  2110. (*Uniform3fvARB)(uniformLocation, 1, uniform);
  2111. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2112. /* Query it back */
  2113. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2114. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2115. /* Clean up before we check to see whether it came back unscathed */
  2116. exercise_uniform_end(program);
  2117. /* Now check to see whether the uniform came back as expected. This
  2118. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2119. */
  2120. return compare_floats(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2121. }
  2122. static GLboolean
  2123. test_Uniform3f(generic_func func)
  2124. {
  2125. PFNGLUNIFORM3FARBPROC Uniform3fARB = (PFNGLUNIFORM3FARBPROC) func;
  2126. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2127. /* This is a trivial fragment shader that sets the color of the
  2128. * fragment to the uniform value passed in.
  2129. */
  2130. static const char *fragmentShaderText =
  2131. "uniform vec3 uniformColor;"
  2132. "void main() {gl_FragColor.rgb = uniformColor;}";
  2133. static const char *uniformName = "uniformColor";
  2134. GLhandleARB program;
  2135. GLint uniformLocation;
  2136. const GLfloat uniform[3] = {1.1,2.2,3.3};
  2137. GLfloat queriedUniform[3];
  2138. if (GetUniformfvARB == NULL) {
  2139. return GL_FALSE;
  2140. }
  2141. /* Call a helper function to compile up the shader and give
  2142. * us back the validated program and uniform location.
  2143. * If it fails, something's wrong and we can't continue.
  2144. */
  2145. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2146. &program, &uniformLocation)) {
  2147. return GL_FALSE;
  2148. }
  2149. /* Set the value of the program uniform. Note that you must
  2150. * use a compatible type. Our uniform above is a float
  2151. * vector 3 (vec3), so we must set it using float versions
  2152. * of the Uniform* functions.
  2153. */
  2154. (*Uniform3fARB)(uniformLocation, uniform[0], uniform[1], uniform[2]);
  2155. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2156. /* Query it back */
  2157. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2158. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2159. /* Clean up before we check to see whether it came back unscathed */
  2160. exercise_uniform_end(program);
  2161. /* Now check to see whether the uniform came back as expected. This
  2162. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2163. */
  2164. return compare_floats(__FUNCTION__, 3, uniform, 3, queriedUniform);
  2165. }
  2166. static GLboolean
  2167. test_Uniform4iv(generic_func func)
  2168. {
  2169. PFNGLUNIFORM4IVARBPROC Uniform4ivARB = (PFNGLUNIFORM4IVARBPROC) func;
  2170. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  2171. /* This is a trivial fragment shader that sets the color of the
  2172. * fragment to the uniform value passed in.
  2173. */
  2174. static const char *fragmentShaderText =
  2175. "uniform ivec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2176. static const char *uniformName = "uniformColor";
  2177. GLhandleARB program;
  2178. GLint uniformLocation;
  2179. const GLint uniform[4] = {1,2,3,4};
  2180. GLint queriedUniform[4];
  2181. if (GetUniformivARB == NULL) {
  2182. return GL_FALSE;
  2183. }
  2184. /* Call a helper function to compile up the shader and give
  2185. * us back the validated program and uniform location.
  2186. * If it fails, something's wrong and we can't continue.
  2187. */
  2188. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2189. &program, &uniformLocation)) {
  2190. return GL_FALSE;
  2191. }
  2192. /* Set the value of the program uniform. Note that you must
  2193. * use a compatible type. Our uniform above is an integer
  2194. * vector (ivec4), so we must set it using integer versions
  2195. * of the Uniform* functions. The "1" means we're setting
  2196. * one vector's worth of information.
  2197. */
  2198. (*Uniform4ivARB)(uniformLocation, 1, uniform);
  2199. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2200. /* Query it back */
  2201. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2202. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2203. /* Clean up before we check to see whether it came back unscathed */
  2204. exercise_uniform_end(program);
  2205. /* Now check to see whether the uniform came back as expected. This
  2206. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2207. */
  2208. return compare_ints(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2209. }
  2210. static GLboolean
  2211. test_Uniform4i(generic_func func)
  2212. {
  2213. PFNGLUNIFORM4IARBPROC Uniform4iARB = (PFNGLUNIFORM4IARBPROC) func;
  2214. DECLARE_GLFUNC_PTR(GetUniformivARB, PFNGLGETUNIFORMIVARBPROC);
  2215. /* This is a trivial fragment shader that sets the color of the
  2216. * fragment to the uniform value passed in.
  2217. */
  2218. static const char *fragmentShaderText =
  2219. "uniform ivec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2220. static const char *uniformName = "uniformColor";
  2221. GLhandleARB program;
  2222. GLint uniformLocation;
  2223. const GLint uniform[4] = {1,2,3,4};
  2224. GLint queriedUniform[4];
  2225. if (GetUniformivARB == NULL) {
  2226. return GL_FALSE;
  2227. }
  2228. /* Call a helper function to compile up the shader and give
  2229. * us back the validated program and uniform location.
  2230. * If it fails, something's wrong and we can't continue.
  2231. */
  2232. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2233. &program, &uniformLocation)) {
  2234. return GL_FALSE;
  2235. }
  2236. /* Set the value of the program uniform. Note that you must
  2237. * use a compatible type. Our uniform above is an integer
  2238. * vector (ivec4), so we must set it using integer versions
  2239. * of the Uniform* functions.
  2240. */
  2241. (*Uniform4iARB)(uniformLocation, uniform[0], uniform[1], uniform[2],
  2242. uniform[3]);
  2243. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2244. /* Query it back */
  2245. (*GetUniformivARB)(program, uniformLocation, queriedUniform);
  2246. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2247. /* Clean up before we check to see whether it came back unscathed */
  2248. exercise_uniform_end(program);
  2249. /* Now check to see whether the uniform came back as expected. This
  2250. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2251. */
  2252. return compare_ints(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2253. }
  2254. static GLboolean
  2255. test_Uniform4fv(generic_func func)
  2256. {
  2257. PFNGLUNIFORM4FVARBPROC Uniform4fvARB = (PFNGLUNIFORM4FVARBPROC) func;
  2258. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2259. /* This is a trivial fragment shader that sets the color of the
  2260. * fragment to the uniform value passed in.
  2261. */
  2262. static const char *fragmentShaderText =
  2263. "uniform vec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2264. static const char *uniformName = "uniformColor";
  2265. GLhandleARB program;
  2266. GLint uniformLocation;
  2267. const GLfloat uniform[4] = {1.1,2.2,3.3,4.4};
  2268. GLfloat queriedUniform[4];
  2269. if (GetUniformfvARB == NULL) {
  2270. return GL_FALSE;
  2271. }
  2272. /* Call a helper function to compile up the shader and give
  2273. * us back the validated program and uniform location.
  2274. * If it fails, something's wrong and we can't continue.
  2275. */
  2276. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2277. &program, &uniformLocation)) {
  2278. return GL_FALSE;
  2279. }
  2280. /* Set the value of the program uniform. Note that you must
  2281. * use a compatible type. Our uniform above is a float
  2282. * vector (vec4), so we must set it using float versions
  2283. * of the Uniform* functions. The "1" means we're setting
  2284. * one vector's worth of information.
  2285. */
  2286. (*Uniform4fvARB)(uniformLocation, 1, uniform);
  2287. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2288. /* Query it back */
  2289. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2290. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2291. /* Clean up before we check to see whether it came back unscathed */
  2292. exercise_uniform_end(program);
  2293. /* Now check to see whether the uniform came back as expected. This
  2294. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2295. */
  2296. return compare_floats(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2297. }
  2298. static GLboolean
  2299. test_Uniform4f(generic_func func)
  2300. {
  2301. PFNGLUNIFORM4FARBPROC Uniform4fARB = (PFNGLUNIFORM4FARBPROC) func;
  2302. DECLARE_GLFUNC_PTR(GetUniformfvARB, PFNGLGETUNIFORMFVARBPROC);
  2303. /* This is a trivial fragment shader that sets the color of the
  2304. * fragment to the uniform value passed in.
  2305. */
  2306. static const char *fragmentShaderText =
  2307. "uniform vec4 uniformColor; void main() {gl_FragColor = uniformColor;}";
  2308. static const char *uniformName = "uniformColor";
  2309. GLhandleARB program;
  2310. GLint uniformLocation;
  2311. const GLfloat uniform[4] = {1.1,2.2,3.3,4.4};
  2312. GLfloat queriedUniform[4];
  2313. if (GetUniformfvARB == NULL) {
  2314. return GL_FALSE;
  2315. }
  2316. /* Call a helper function to compile up the shader and give
  2317. * us back the validated program and uniform location.
  2318. * If it fails, something's wrong and we can't continue.
  2319. */
  2320. if (!exercise_uniform_start(fragmentShaderText, uniformName,
  2321. &program, &uniformLocation)) {
  2322. return GL_FALSE;
  2323. }
  2324. /* Set the value of the program uniform. Note that you must
  2325. * use a compatible type. Our uniform above is an integer
  2326. * vector (ivec4), so we must set it using integer versions
  2327. * of the Uniform* functions.
  2328. */
  2329. (*Uniform4fARB)(uniformLocation, uniform[0], uniform[1], uniform[2],
  2330. uniform[3]);
  2331. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2332. /* Query it back */
  2333. (*GetUniformfvARB)(program, uniformLocation, queriedUniform);
  2334. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  2335. /* Clean up before we check to see whether it came back unscathed */
  2336. exercise_uniform_end(program);
  2337. /* Now check to see whether the uniform came back as expected. This
  2338. * will return GL_TRUE if all is well, or GL_FALSE if the comparison failed.
  2339. */
  2340. return compare_floats(__FUNCTION__, 4, uniform, 4, queriedUniform);
  2341. }
  2342. static GLboolean
  2343. test_ActiveTextureARB(generic_func func)
  2344. {
  2345. PFNGLACTIVETEXTUREARBPROC activeTexture = (PFNGLACTIVETEXTUREARBPROC) func;
  2346. GLint t;
  2347. GLboolean pass;
  2348. (*activeTexture)(GL_TEXTURE1_ARB);
  2349. glGetIntegerv(GL_ACTIVE_TEXTURE_ARB, &t);
  2350. pass = (t == GL_TEXTURE1_ARB);
  2351. (*activeTexture)(GL_TEXTURE0_ARB); /* restore default */
  2352. return pass;
  2353. }
  2354. static GLboolean
  2355. test_SecondaryColor3fEXT(generic_func func)
  2356. {
  2357. PFNGLSECONDARYCOLOR3FEXTPROC secColor3f = (PFNGLSECONDARYCOLOR3FEXTPROC) func;
  2358. GLfloat color[4];
  2359. GLboolean pass;
  2360. (*secColor3f)(1.0, 1.0, 0.0);
  2361. glGetFloatv(GL_CURRENT_SECONDARY_COLOR_EXT, color);
  2362. pass = (color[0] == 1.0 && color[1] == 1.0 && color[2] == 0.0);
  2363. (*secColor3f)(0.0, 0.0, 0.0); /* restore default */
  2364. return pass;
  2365. }
  2366. static GLboolean
  2367. test_ActiveStencilFaceEXT(generic_func func)
  2368. {
  2369. PFNGLACTIVESTENCILFACEEXTPROC activeFace = (PFNGLACTIVESTENCILFACEEXTPROC) func;
  2370. GLint face;
  2371. GLboolean pass;
  2372. (*activeFace)(GL_BACK);
  2373. glGetIntegerv(GL_ACTIVE_STENCIL_FACE_EXT, &face);
  2374. pass = (face == GL_BACK);
  2375. (*activeFace)(GL_FRONT); /* restore default */
  2376. return pass;
  2377. }
  2378. static GLboolean
  2379. test_VertexAttrib1fvARB(generic_func func)
  2380. {
  2381. PFNGLVERTEXATTRIB1FVARBPROC vertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC) func;
  2382. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2383. const GLfloat v[1] = {25.0};
  2384. const GLfloat def[1] = {0};
  2385. GLfloat res[4];
  2386. GLboolean pass;
  2387. (*vertexAttrib1fvARB)(6, v);
  2388. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2389. pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0);
  2390. (*vertexAttrib1fvARB)(6, def);
  2391. return pass;
  2392. }
  2393. static GLboolean
  2394. test_VertexAttrib1dvARB(generic_func func)
  2395. {
  2396. PFNGLVERTEXATTRIB1DVARBPROC vertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC) func;
  2397. PFNGLGETVERTEXATTRIBDVARBPROC getVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvARB");
  2398. const GLdouble v[1] = {25.0};
  2399. const GLdouble def[1] = {0};
  2400. GLdouble res[4];
  2401. GLboolean pass;
  2402. (*vertexAttrib1dvARB)(6, v);
  2403. (*getVertexAttribdvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2404. pass = (res[0] == 25.0 && res[1] == 0.0 && res[2] == 0.0 && res[3] == 1.0);
  2405. (*vertexAttrib1dvARB)(6, def);
  2406. return pass;
  2407. }
  2408. static GLboolean
  2409. test_VertexAttrib1svARB(generic_func func)
  2410. {
  2411. PFNGLVERTEXATTRIB1SVARBPROC vertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC) func;
  2412. PFNGLGETVERTEXATTRIBIVARBPROC getVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivARB");
  2413. const GLshort v[1] = {25.0};
  2414. const GLshort def[1] = {0};
  2415. GLint res[4];
  2416. GLboolean pass;
  2417. (*vertexAttrib1svARB)(6, v);
  2418. (*getVertexAttribivARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2419. pass = (res[0] == 25 && res[1] == 0 && res[2] == 0 && res[3] == 1);
  2420. (*vertexAttrib1svARB)(6, def);
  2421. return pass;
  2422. }
  2423. static GLboolean
  2424. test_VertexAttrib4NubvARB(generic_func func)
  2425. {
  2426. PFNGLVERTEXATTRIB4NUBVARBPROC vertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC) func;
  2427. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2428. const GLubyte v[4] = {255, 0, 255, 0};
  2429. const GLubyte def[4] = {0, 0, 0, 255};
  2430. GLfloat res[4];
  2431. GLboolean pass;
  2432. (*vertexAttrib4NubvARB)(6, v);
  2433. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2434. pass = (res[0] == 1.0 && res[1] == 0.0 && res[2] == 1.0 && res[3] == 0.0);
  2435. (*vertexAttrib4NubvARB)(6, def);
  2436. return pass;
  2437. }
  2438. static GLboolean
  2439. test_VertexAttrib4NuivARB(generic_func func)
  2440. {
  2441. PFNGLVERTEXATTRIB4NUIVARBPROC vertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC) func;
  2442. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2443. const GLuint v[4] = {0xffffffff, 0, 0xffffffff, 0};
  2444. const GLuint def[4] = {0, 0, 0, 0xffffffff};
  2445. GLfloat res[4];
  2446. GLboolean pass;
  2447. (*vertexAttrib4NuivARB)(6, v);
  2448. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2449. pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
  2450. (*vertexAttrib4NuivARB)(6, def);
  2451. return pass;
  2452. }
  2453. static GLboolean
  2454. test_VertexAttrib4ivARB(generic_func func)
  2455. {
  2456. PFNGLVERTEXATTRIB4IVARBPROC vertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC) func;
  2457. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2458. const GLint v[4] = {1, 2, -3, 4};
  2459. const GLint def[4] = {0, 0, 0, 1};
  2460. GLfloat res[4];
  2461. GLboolean pass;
  2462. (*vertexAttrib4ivARB)(6, v);
  2463. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2464. pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 2.0) && EQUAL(res[2], -3.0) && EQUAL(res[3], 4.0));
  2465. (*vertexAttrib4ivARB)(6, def);
  2466. return pass;
  2467. }
  2468. static GLboolean
  2469. test_VertexAttrib4NsvARB(generic_func func)
  2470. {
  2471. PFNGLVERTEXATTRIB4NSVARBPROC vertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC) func;
  2472. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2473. const GLshort v[4] = {0, 32767, 32767, 0};
  2474. const GLshort def[4] = {0, 0, 0, 32767};
  2475. GLfloat res[4];
  2476. GLboolean pass;
  2477. (*vertexAttrib4NsvARB)(6, v);
  2478. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2479. pass = (EQUAL(res[0], 0.0) && EQUAL(res[1], 1.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
  2480. (*vertexAttrib4NsvARB)(6, def);
  2481. return pass;
  2482. }
  2483. static GLboolean
  2484. test_VertexAttrib4NusvARB(generic_func func)
  2485. {
  2486. PFNGLVERTEXATTRIB4NUSVARBPROC vertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC) func;
  2487. PFNGLGETVERTEXATTRIBFVARBPROC getVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvARB");
  2488. const GLushort v[4] = {0xffff, 0, 0xffff, 0};
  2489. const GLushort def[4] = {0, 0, 0, 0xffff};
  2490. GLfloat res[4];
  2491. GLboolean pass;
  2492. (*vertexAttrib4NusvARB)(6, v);
  2493. (*getVertexAttribfvARB)(6, GL_CURRENT_VERTEX_ATTRIB_ARB, res);
  2494. pass = (EQUAL(res[0], 1.0) && EQUAL(res[1], 0.0) && EQUAL(res[2], 1.0) && EQUAL(res[3], 0.0));
  2495. (*vertexAttrib4NusvARB)(6, def);
  2496. return pass;
  2497. }
  2498. static GLboolean
  2499. test_VertexAttrib1sNV(generic_func func)
  2500. {
  2501. PFNGLVERTEXATTRIB1SNVPROC vertexAttrib1sNV = (PFNGLVERTEXATTRIB1SNVPROC) func;
  2502. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2503. const GLshort v[4] = {2, 0, 0, 1};
  2504. const GLshort def[4] = {0, 0, 0, 1};
  2505. GLint res[4];
  2506. (*vertexAttrib1sNV)(6, v[0]);
  2507. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2508. (*vertexAttrib1sNV)(6, def[0]);
  2509. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2510. }
  2511. static GLboolean
  2512. test_VertexAttrib1fNV(generic_func func)
  2513. {
  2514. PFNGLVERTEXATTRIB1FNVPROC vertexAttrib1fNV = (PFNGLVERTEXATTRIB1FNVPROC) func;
  2515. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2516. const GLfloat v[4] = {2.5, 0.0, 0.0, 1.0};
  2517. const GLfloat def[4] = {0, 0, 0, 1};
  2518. GLfloat res[4];
  2519. (*vertexAttrib1fNV)(6, v[0]);
  2520. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2521. (*vertexAttrib1fNV)(6, def[0]);
  2522. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2523. }
  2524. static GLboolean
  2525. test_VertexAttrib1dNV(generic_func func)
  2526. {
  2527. PFNGLVERTEXATTRIB1DNVPROC vertexAttrib1dNV = (PFNGLVERTEXATTRIB1DNVPROC) func;
  2528. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2529. const GLdouble v[4] = {2.5, 0.0, 0.0, 1.0};
  2530. const GLdouble def[4] = {0, 0, 0, 1};
  2531. GLdouble res[4];
  2532. (*vertexAttrib1dNV)(6, v[0]);
  2533. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2534. (*vertexAttrib1dNV)(6, def[0]);
  2535. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2536. }
  2537. static GLboolean
  2538. test_VertexAttrib2sNV(generic_func func)
  2539. {
  2540. PFNGLVERTEXATTRIB2SNVPROC vertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC) func;
  2541. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2542. const GLshort v[4] = {2, 4, 0, 1};
  2543. const GLshort def[4] = {0, 0, 0, 1};
  2544. GLint res[4];
  2545. (*vertexAttrib2sNV)(6, v[0], v[1]);
  2546. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2547. (*vertexAttrib2sNV)(6, def[0], def[1]);
  2548. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2549. }
  2550. static GLboolean
  2551. test_VertexAttrib2fNV(generic_func func)
  2552. {
  2553. PFNGLVERTEXATTRIB2FNVPROC vertexAttrib2fNV = (PFNGLVERTEXATTRIB2FNVPROC) func;
  2554. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2555. const GLfloat v[4] = {2.5, 4.25, 0.0, 1.0};
  2556. const GLfloat def[4] = {0, 0, 0, 1};
  2557. GLfloat res[4];
  2558. (*vertexAttrib2fNV)(6, v[0], v[1]);
  2559. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2560. (*vertexAttrib2fNV)(6, def[0], def[1]);
  2561. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2562. }
  2563. static GLboolean
  2564. test_VertexAttrib2dNV(generic_func func)
  2565. {
  2566. PFNGLVERTEXATTRIB2DNVPROC vertexAttrib2dNV = (PFNGLVERTEXATTRIB2DNVPROC) func;
  2567. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2568. const GLdouble v[4] = {2.5, 4.25, 0.0, 1.0};
  2569. const GLdouble def[4] = {0, 0, 0, 1};
  2570. GLdouble res[4];
  2571. (*vertexAttrib2dNV)(6, v[0], v[1]);
  2572. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2573. (*vertexAttrib2dNV)(6, def[0], def[1]);
  2574. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2575. }
  2576. static GLboolean
  2577. test_VertexAttrib3sNV(generic_func func)
  2578. {
  2579. PFNGLVERTEXATTRIB3SNVPROC vertexAttrib3sNV = (PFNGLVERTEXATTRIB3SNVPROC) func;
  2580. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2581. const GLshort v[4] = {2, 4, 7, 1};
  2582. const GLshort def[4] = {0, 0, 0, 1};
  2583. GLint res[4];
  2584. (*vertexAttrib3sNV)(6, v[0], v[1], v[2]);
  2585. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2586. (*vertexAttrib3sNV)(6, def[0], def[1], def[2]);
  2587. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2588. }
  2589. static GLboolean
  2590. test_VertexAttrib3fNV(generic_func func)
  2591. {
  2592. PFNGLVERTEXATTRIB3FNVPROC vertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC) func;
  2593. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2594. const GLfloat v[4] = {2.5, 4.25, 7.125, 1.0};
  2595. const GLfloat def[4] = {0, 0, 0, 1};
  2596. GLfloat res[4];
  2597. (*vertexAttrib3fNV)(6, v[0], v[1], v[2]);
  2598. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2599. (*vertexAttrib3fNV)(6, def[0], def[1], def[2]);
  2600. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2601. }
  2602. static GLboolean
  2603. test_VertexAttrib3dNV(generic_func func)
  2604. {
  2605. PFNGLVERTEXATTRIB3DNVPROC vertexAttrib3dNV = (PFNGLVERTEXATTRIB3DNVPROC) func;
  2606. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2607. const GLdouble v[4] = {2.5, 4.25, 7.125, 1.0};
  2608. const GLdouble def[4] = {0, 0, 0, 1};
  2609. GLdouble res[4];
  2610. (*vertexAttrib3dNV)(6, v[0], v[1], v[2]);
  2611. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2612. (*vertexAttrib3dNV)(6, def[0], def[1], def[2]);
  2613. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2614. }
  2615. static GLboolean
  2616. test_VertexAttrib4sNV(generic_func func)
  2617. {
  2618. PFNGLVERTEXATTRIB4SNVPROC vertexAttrib4sNV = (PFNGLVERTEXATTRIB4SNVPROC) func;
  2619. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2620. const GLshort v[4] = {2, 4, 7, 5};
  2621. const GLshort def[4] = {0, 0, 0, 1};
  2622. GLint res[4];
  2623. (*vertexAttrib4sNV)(6, v[0], v[1], v[2], v[3]);
  2624. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2625. (*vertexAttrib4sNV)(6, def[0], def[1], def[2], def[3]);
  2626. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2627. }
  2628. static GLboolean
  2629. test_VertexAttrib4fNV(generic_func func)
  2630. {
  2631. PFNGLVERTEXATTRIB4FNVPROC vertexAttrib4fNV = (PFNGLVERTEXATTRIB4FNVPROC) func;
  2632. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2633. const GLfloat v[4] = {2.5, 4.25, 7.125, 5.0625};
  2634. const GLfloat def[4] = {0, 0, 0, 1};
  2635. GLfloat res[4];
  2636. (*vertexAttrib4fNV)(6, v[0], v[1], v[2], v[3]);
  2637. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2638. (*vertexAttrib4fNV)(6, def[0], def[1], def[2], def[3]);
  2639. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2640. }
  2641. static GLboolean
  2642. test_VertexAttrib4dNV(generic_func func)
  2643. {
  2644. PFNGLVERTEXATTRIB4DNVPROC vertexAttrib4dNV = (PFNGLVERTEXATTRIB4DNVPROC) func;
  2645. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2646. const GLdouble v[4] = {2.5, 4.25, 7.125, 5.0625};
  2647. const GLdouble def[4] = {0, 0, 0, 1};
  2648. GLdouble res[4];
  2649. (*vertexAttrib4dNV)(6, v[0], v[1], v[2], v[3]);
  2650. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2651. (*vertexAttrib4dNV)(6, def[0], def[1], def[2], def[3]);
  2652. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2653. }
  2654. static GLboolean
  2655. test_VertexAttrib4ubNV(generic_func func)
  2656. {
  2657. PFNGLVERTEXATTRIB4UBNVPROC vertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC) func;
  2658. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2659. const GLubyte v[4] = {255, 0, 255, 0};
  2660. const GLubyte def[4] = {0, 0, 0, 255};
  2661. GLfloat res[4];
  2662. /* There's no byte-value query; so we use the float-value query.
  2663. * Bytes are interpreted as steps between 0 and 1, so the
  2664. * expected float values will be 0.0 for byte value 0 and 1.0 for
  2665. * byte value 255.
  2666. */
  2667. GLfloat expectedResults[4] = {1.0, 0.0, 1.0, 0.0};
  2668. (*vertexAttrib4ubNV)(6, v[0], v[1], v[2], v[3]);
  2669. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2670. (*vertexAttrib4ubNV)(6, def[0], def[1], def[2], def[3]);
  2671. return compare_floats(__FUNCTION__, 4, expectedResults, 4, res);
  2672. }
  2673. static GLboolean
  2674. test_VertexAttrib1fvNV(generic_func func)
  2675. {
  2676. PFNGLVERTEXATTRIB1FVNVPROC vertexAttrib1fvNV = (PFNGLVERTEXATTRIB1FVNVPROC) func;
  2677. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2678. const GLfloat v[4] = {2.5, 0.0, 0.0, 1.0};
  2679. const GLfloat def[4] = {0, 0, 0, 1};
  2680. GLfloat res[4];
  2681. (*vertexAttrib1fvNV)(6, v);
  2682. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2683. (*vertexAttrib1fvNV)(6, def);
  2684. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2685. }
  2686. static GLboolean
  2687. test_VertexAttrib1dvNV(generic_func func)
  2688. {
  2689. PFNGLVERTEXATTRIB1DVNVPROC vertexAttrib1dvNV = (PFNGLVERTEXATTRIB1DVNVPROC) func;
  2690. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2691. const GLdouble v[4] = {2.5, 0.0, 0.0, 1.0};
  2692. const GLdouble def[4] = {0, 0, 0, 1};
  2693. GLdouble res[4];
  2694. (*vertexAttrib1dvNV)(6, v);
  2695. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2696. (*vertexAttrib1dvNV)(6, def);
  2697. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2698. }
  2699. static GLboolean
  2700. test_VertexAttrib2svNV(generic_func func)
  2701. {
  2702. PFNGLVERTEXATTRIB2SVNVPROC vertexAttrib2svNV = (PFNGLVERTEXATTRIB2SVNVPROC) func;
  2703. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2704. const GLshort v[4] = {2, 4, 0, 1};
  2705. const GLshort def[4] = {0, 0, 0, 1};
  2706. GLint res[4];
  2707. (*vertexAttrib2svNV)(6, v);
  2708. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2709. (*vertexAttrib2svNV)(6, def);
  2710. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2711. }
  2712. static GLboolean
  2713. test_VertexAttrib2fvNV(generic_func func)
  2714. {
  2715. PFNGLVERTEXATTRIB2FVNVPROC vertexAttrib2fvNV = (PFNGLVERTEXATTRIB2FVNVPROC) func;
  2716. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2717. const GLfloat v[4] = {2.5, 4.25, 0.0, 1.0};
  2718. const GLfloat def[4] = {0, 0, 0, 1};
  2719. GLfloat res[4];
  2720. (*vertexAttrib2fvNV)(6, v);
  2721. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2722. (*vertexAttrib2fvNV)(6, def);
  2723. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2724. }
  2725. static GLboolean
  2726. test_VertexAttrib2dvNV(generic_func func)
  2727. {
  2728. PFNGLVERTEXATTRIB2DVNVPROC vertexAttrib2dvNV = (PFNGLVERTEXATTRIB2DVNVPROC) func;
  2729. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2730. const GLdouble v[4] = {2.5, 4.25, 0.0, 1.0};
  2731. const GLdouble def[4] = {0, 0, 0, 1};
  2732. GLdouble res[4];
  2733. (*vertexAttrib2dvNV)(6, v);
  2734. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2735. (*vertexAttrib2dvNV)(6, def);
  2736. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2737. }
  2738. static GLboolean
  2739. test_VertexAttrib3svNV(generic_func func)
  2740. {
  2741. PFNGLVERTEXATTRIB3SVNVPROC vertexAttrib3svNV = (PFNGLVERTEXATTRIB3SVNVPROC) func;
  2742. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2743. const GLshort v[4] = {2, 4, 7, 1};
  2744. const GLshort def[4] = {0, 0, 0, 1};
  2745. GLint res[4];
  2746. (*vertexAttrib3svNV)(6, v);
  2747. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2748. (*vertexAttrib3svNV)(6, def);
  2749. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2750. }
  2751. static GLboolean
  2752. test_VertexAttrib3fvNV(generic_func func)
  2753. {
  2754. PFNGLVERTEXATTRIB3FVNVPROC vertexAttrib3fvNV = (PFNGLVERTEXATTRIB3FVNVPROC) func;
  2755. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2756. const GLfloat v[4] = {2.5, 4.25, 7.125, 1.0};
  2757. const GLfloat def[4] = {0, 0, 0, 1};
  2758. GLfloat res[4];
  2759. (*vertexAttrib3fvNV)(6, v);
  2760. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2761. (*vertexAttrib3fvNV)(6, def);
  2762. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2763. }
  2764. static GLboolean
  2765. test_VertexAttrib3dvNV(generic_func func)
  2766. {
  2767. PFNGLVERTEXATTRIB3DVNVPROC vertexAttrib3dvNV = (PFNGLVERTEXATTRIB3DVNVPROC) func;
  2768. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2769. const GLdouble v[4] = {2.5, 4.25, 7.125, 1.0};
  2770. const GLdouble def[4] = {0, 0, 0, 1};
  2771. GLdouble res[4];
  2772. (*vertexAttrib3dvNV)(6, v);
  2773. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2774. (*vertexAttrib3dvNV)(6, def);
  2775. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2776. }
  2777. static GLboolean
  2778. test_VertexAttrib4svNV(generic_func func)
  2779. {
  2780. PFNGLVERTEXATTRIB4SVNVPROC vertexAttrib4svNV = (PFNGLVERTEXATTRIB4SVNVPROC) func;
  2781. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2782. const GLshort v[4] = {2, 4, 7, 5};
  2783. const GLshort def[4] = {0, 0, 0, 1};
  2784. GLint res[4];
  2785. (*vertexAttrib4svNV)(6, v);
  2786. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2787. (*vertexAttrib4svNV)(6, def);
  2788. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2789. }
  2790. static GLboolean
  2791. test_VertexAttrib4fvNV(generic_func func)
  2792. {
  2793. PFNGLVERTEXATTRIB4FVNVPROC vertexAttrib4fvNV = (PFNGLVERTEXATTRIB4FVNVPROC) func;
  2794. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2795. const GLfloat v[4] = {2.5, 4.25, 7.125, 5.0625};
  2796. const GLfloat def[4] = {0, 0, 0, 1};
  2797. GLfloat res[4];
  2798. (*vertexAttrib4fvNV)(6, v);
  2799. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2800. (*vertexAttrib4fvNV)(6, def);
  2801. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2802. }
  2803. static GLboolean
  2804. test_VertexAttrib4dvNV(generic_func func)
  2805. {
  2806. PFNGLVERTEXATTRIB4DVNVPROC vertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC) func;
  2807. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2808. const GLdouble v[4] = {2.5, 4.25, 7.125, 5.0625};
  2809. const GLdouble def[4] = {0, 0, 0, 1};
  2810. GLdouble res[4];
  2811. (*vertexAttrib4dvNV)(6, v);
  2812. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2813. (*vertexAttrib4dvNV)(6, def);
  2814. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2815. }
  2816. static GLboolean
  2817. test_VertexAttrib4ubvNV(generic_func func)
  2818. {
  2819. PFNGLVERTEXATTRIB4UBVNVPROC vertexAttrib4ubvNV = (PFNGLVERTEXATTRIB4UBVNVPROC) func;
  2820. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2821. const GLubyte v[4] = {255, 0, 255, 0};
  2822. const GLubyte def[4] = {0, 0, 0, 255};
  2823. GLfloat res[4];
  2824. /* There's no byte-value query; so we use the float-value query.
  2825. * Bytes are interpreted as steps between 0 and 1, so the
  2826. * expected float values will be 0.0 for byte value 0 and 1.0 for
  2827. * byte value 255.
  2828. */
  2829. GLfloat expectedResults[4] = {1.0, 0.0, 1.0, 0.0};
  2830. (*vertexAttrib4ubvNV)(6, v);
  2831. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2832. (*vertexAttrib4ubvNV)(6, def);
  2833. return compare_floats(__FUNCTION__, 4, expectedResults, 4, res);
  2834. }
  2835. static GLboolean
  2836. test_VertexAttribs1fvNV(generic_func func)
  2837. {
  2838. PFNGLVERTEXATTRIBS1FVNVPROC vertexAttribs1fvNV = (PFNGLVERTEXATTRIBS1FVNVPROC) func;
  2839. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2840. const GLfloat v[4] = {2.5, 0.0, 0.0, 1.0};
  2841. const GLfloat def[4] = {0, 0, 0, 1};
  2842. GLfloat res[4];
  2843. (*vertexAttribs1fvNV)(6, 1, v);
  2844. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2845. (*vertexAttribs1fvNV)(6, 1, def);
  2846. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2847. }
  2848. static GLboolean
  2849. test_VertexAttribs1dvNV(generic_func func)
  2850. {
  2851. PFNGLVERTEXATTRIBS1DVNVPROC vertexAttribs1dvNV = (PFNGLVERTEXATTRIBS1DVNVPROC) func;
  2852. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2853. const GLdouble v[4] = {2.5, 0.0, 0.0, 1.0};
  2854. const GLdouble def[4] = {0, 0, 0, 1};
  2855. GLdouble res[4];
  2856. (*vertexAttribs1dvNV)(6, 1, v);
  2857. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2858. (*vertexAttribs1dvNV)(6, 1, def);
  2859. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2860. }
  2861. static GLboolean
  2862. test_VertexAttribs2svNV(generic_func func)
  2863. {
  2864. PFNGLVERTEXATTRIBS2SVNVPROC vertexAttribs2svNV = (PFNGLVERTEXATTRIBS2SVNVPROC) func;
  2865. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2866. const GLshort v[4] = {2, 4, 0, 1};
  2867. const GLshort def[4] = {0, 0, 0, 1};
  2868. GLint res[4];
  2869. (*vertexAttribs2svNV)(6, 1, v);
  2870. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2871. (*vertexAttribs2svNV)(6, 1, def);
  2872. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2873. }
  2874. static GLboolean
  2875. test_VertexAttribs2fvNV(generic_func func)
  2876. {
  2877. PFNGLVERTEXATTRIBS2FVNVPROC vertexAttribs2fvNV = (PFNGLVERTEXATTRIBS2FVNVPROC) func;
  2878. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2879. const GLfloat v[4] = {2.5, 4.25, 0.0, 1.0};
  2880. const GLfloat def[4] = {0, 0, 0, 1};
  2881. GLfloat res[4];
  2882. (*vertexAttribs2fvNV)(6, 1, v);
  2883. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2884. (*vertexAttribs2fvNV)(6, 1, def);
  2885. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2886. }
  2887. static GLboolean
  2888. test_VertexAttribs2dvNV(generic_func func)
  2889. {
  2890. PFNGLVERTEXATTRIBS2DVNVPROC vertexAttribs2dvNV = (PFNGLVERTEXATTRIBS2DVNVPROC) func;
  2891. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2892. const GLdouble v[4] = {2.5, 4.25, 0.0, 1.0};
  2893. const GLdouble def[4] = {0, 0, 0, 1};
  2894. GLdouble res[4];
  2895. (*vertexAttribs2dvNV)(6, 1, v);
  2896. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2897. (*vertexAttribs2dvNV)(6, 1, def);
  2898. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2899. }
  2900. static GLboolean
  2901. test_VertexAttribs3svNV(generic_func func)
  2902. {
  2903. PFNGLVERTEXATTRIBS3SVNVPROC vertexAttribs3svNV = (PFNGLVERTEXATTRIBS3SVNVPROC) func;
  2904. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2905. const GLshort v[4] = {2, 4, 7, 1};
  2906. const GLshort def[4] = {0, 0, 0, 1};
  2907. GLint res[4];
  2908. (*vertexAttribs3svNV)(6, 1, v);
  2909. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2910. (*vertexAttribs3svNV)(6, 1, def);
  2911. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2912. }
  2913. static GLboolean
  2914. test_VertexAttribs3fvNV(generic_func func)
  2915. {
  2916. PFNGLVERTEXATTRIBS3FVNVPROC vertexAttribs3fvNV = (PFNGLVERTEXATTRIBS3FVNVPROC) func;
  2917. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2918. const GLfloat v[4] = {2.5, 4.25, 7.125, 1.0};
  2919. const GLfloat def[4] = {0, 0, 0, 1};
  2920. GLfloat res[4];
  2921. (*vertexAttribs3fvNV)(6, 1, v);
  2922. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2923. (*vertexAttribs3fvNV)(6, 1, def);
  2924. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2925. }
  2926. static GLboolean
  2927. test_VertexAttribs3dvNV(generic_func func)
  2928. {
  2929. PFNGLVERTEXATTRIBS3DVNVPROC vertexAttribs3dvNV = (PFNGLVERTEXATTRIBS3DVNVPROC) func;
  2930. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2931. const GLdouble v[4] = {2.5, 4.25, 7.125, 1.0};
  2932. const GLdouble def[4] = {0, 0, 0, 1};
  2933. GLdouble res[4];
  2934. (*vertexAttribs3dvNV)(6, 1, v);
  2935. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2936. (*vertexAttribs3dvNV)(6, 1, def);
  2937. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2938. }
  2939. static GLboolean
  2940. test_VertexAttribs4svNV(generic_func func)
  2941. {
  2942. PFNGLVERTEXATTRIBS4SVNVPROC vertexAttribs4svNV = (PFNGLVERTEXATTRIBS4SVNVPROC) func;
  2943. PFNGLGETVERTEXATTRIBIVNVPROC getVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribivNV");
  2944. const GLshort v[4] = {2, 4, 7, 5};
  2945. const GLshort def[4] = {0, 0, 0, 1};
  2946. GLint res[4];
  2947. (*vertexAttribs4svNV)(6, 1, v);
  2948. (*getVertexAttribivNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2949. (*vertexAttribs4svNV)(6, 1, def);
  2950. return compare_shorts_to_ints(__FUNCTION__, 4, v, 4, res);
  2951. }
  2952. static GLboolean
  2953. test_VertexAttribs4fvNV(generic_func func)
  2954. {
  2955. PFNGLVERTEXATTRIBS4FVNVPROC vertexAttribs4fvNV = (PFNGLVERTEXATTRIBS4FVNVPROC) func;
  2956. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2957. const GLfloat v[4] = {2.5, 4.25, 7.125, 5.0625};
  2958. const GLfloat def[4] = {0, 0, 0, 1};
  2959. GLfloat res[4];
  2960. (*vertexAttribs4fvNV)(6, 1, v);
  2961. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2962. (*vertexAttribs4fvNV)(6, 1, def);
  2963. return compare_floats(__FUNCTION__, 4, v, 4, res);
  2964. }
  2965. static GLboolean
  2966. test_VertexAttribs4dvNV(generic_func func)
  2967. {
  2968. PFNGLVERTEXATTRIBS4DVNVPROC vertexAttribs4dvNV = (PFNGLVERTEXATTRIBS4DVNVPROC) func;
  2969. PFNGLGETVERTEXATTRIBDVNVPROC getVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribdvNV");
  2970. const GLdouble v[4] = {2.5, 4.25, 7.125, 5.0625};
  2971. const GLdouble def[4] = {0, 0, 0, 1};
  2972. GLdouble res[4];
  2973. (*vertexAttribs4dvNV)(6, 1, v);
  2974. (*getVertexAttribdvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2975. (*vertexAttribs4dvNV)(6, 1, def);
  2976. return compare_doubles(__FUNCTION__, 4, v, 4, res);
  2977. }
  2978. static GLboolean
  2979. test_VertexAttribs4ubvNV(generic_func func)
  2980. {
  2981. PFNGLVERTEXATTRIBS4UBVNVPROC vertexAttribs4ubvNV = (PFNGLVERTEXATTRIBS4UBVNVPROC) func;
  2982. PFNGLGETVERTEXATTRIBFVNVPROC getVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC) glXGetProcAddressARB((const GLubyte *) "glGetVertexAttribfvNV");
  2983. const GLubyte v[4] = {255, 0, 255, 0};
  2984. const GLubyte def[4] = {0, 0, 0, 255};
  2985. GLfloat res[4];
  2986. /* There's no byte-value query; so we use the float-value query.
  2987. * Bytes are interpreted as steps between 0 and 1, so the
  2988. * expected float values will be 0.0 for byte value 0 and 1.0 for
  2989. * byte value 255.
  2990. */
  2991. GLfloat expectedResults[4] = {1.0, 0.0, 1.0, 0.0};
  2992. (*vertexAttribs4ubvNV)(6, 1, v);
  2993. (*getVertexAttribfvNV)(6, GL_CURRENT_ATTRIB_NV, res);
  2994. (*vertexAttribs4ubvNV)(6, 1, def);
  2995. return compare_floats(__FUNCTION__, 4, expectedResults, 4, res);
  2996. }
  2997. static GLboolean
  2998. test_StencilFuncSeparateATI(generic_func func)
  2999. {
  3000. #ifdef GL_ATI_separate_stencil
  3001. PFNGLSTENCILFUNCSEPARATEATIPROC stencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) func;
  3002. GLint frontFunc, backFunc;
  3003. GLint frontRef, backRef;
  3004. GLint frontMask, backMask;
  3005. (*stencilFuncSeparateATI)(GL_LESS, GL_GREATER, 2, 0xa);
  3006. glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
  3007. glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
  3008. glGetIntegerv(GL_STENCIL_REF, &frontRef);
  3009. glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
  3010. glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
  3011. glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
  3012. if (frontFunc != GL_LESS ||
  3013. backFunc != GL_GREATER ||
  3014. frontRef != 2 ||
  3015. backRef != 2 ||
  3016. frontMask != 0xa ||
  3017. backMask != 0xa)
  3018. return GL_FALSE;
  3019. #endif
  3020. return GL_TRUE;
  3021. }
  3022. static GLboolean
  3023. test_StencilFuncSeparate(generic_func func)
  3024. {
  3025. #ifdef GL_VERSION_2_0
  3026. PFNGLSTENCILFUNCSEPARATEPROC stencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) func;
  3027. GLint frontFunc, backFunc;
  3028. GLint frontRef, backRef;
  3029. GLint frontMask, backMask;
  3030. (*stencilFuncSeparate)(GL_BACK, GL_GREATER, 2, 0xa);
  3031. glGetIntegerv(GL_STENCIL_FUNC, &frontFunc);
  3032. glGetIntegerv(GL_STENCIL_BACK_FUNC, &backFunc);
  3033. glGetIntegerv(GL_STENCIL_REF, &frontRef);
  3034. glGetIntegerv(GL_STENCIL_BACK_REF, &backRef);
  3035. glGetIntegerv(GL_STENCIL_VALUE_MASK, &frontMask);
  3036. glGetIntegerv(GL_STENCIL_BACK_VALUE_MASK, &backMask);
  3037. if (frontFunc != GL_ALWAYS ||
  3038. backFunc != GL_GREATER ||
  3039. frontRef != 0 ||
  3040. backRef != 2 ||
  3041. frontMask == 0xa || /* might be 0xff or ~0 */
  3042. backMask != 0xa)
  3043. return GL_FALSE;
  3044. #endif
  3045. return GL_TRUE;
  3046. }
  3047. static GLboolean
  3048. test_StencilOpSeparate(generic_func func)
  3049. {
  3050. #ifdef GL_VERSION_2_0
  3051. PFNGLSTENCILOPSEPARATEPROC stencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) func;
  3052. GLint frontFail, backFail;
  3053. GLint frontZFail, backZFail;
  3054. GLint frontZPass, backZPass;
  3055. (*stencilOpSeparate)(GL_BACK, GL_INCR, GL_DECR, GL_INVERT);
  3056. glGetIntegerv(GL_STENCIL_FAIL, &frontFail);
  3057. glGetIntegerv(GL_STENCIL_BACK_FAIL, &backFail);
  3058. glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &frontZFail);
  3059. glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_FAIL, &backZFail);
  3060. glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &frontZPass);
  3061. glGetIntegerv(GL_STENCIL_BACK_PASS_DEPTH_PASS, &backZPass);
  3062. if (frontFail != GL_KEEP ||
  3063. backFail != GL_INCR ||
  3064. frontZFail != GL_KEEP ||
  3065. backZFail != GL_DECR ||
  3066. frontZPass != GL_KEEP ||
  3067. backZPass != GL_INVERT)
  3068. return GL_FALSE;
  3069. #endif
  3070. return GL_TRUE;
  3071. }
  3072. static GLboolean
  3073. test_StencilMaskSeparate(generic_func func)
  3074. {
  3075. #ifdef GL_VERSION_2_0
  3076. PFNGLSTENCILMASKSEPARATEPROC stencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) func;
  3077. GLint frontMask, backMask;
  3078. (*stencilMaskSeparate)(GL_BACK, 0x1b);
  3079. glGetIntegerv(GL_STENCIL_WRITEMASK, &frontMask);
  3080. glGetIntegerv(GL_STENCIL_BACK_WRITEMASK, &backMask);
  3081. if (frontMask == 0x1b ||
  3082. backMask != 0x1b)
  3083. return GL_FALSE;
  3084. #endif
  3085. return GL_TRUE;
  3086. }
  3087. /*
  3088. * The following file is auto-generated with Python.
  3089. */
  3090. #include "getproclist.h"
  3091. static int
  3092. extension_supported(const char *haystack, const char *needle)
  3093. {
  3094. const char *p = strstr(haystack, needle);
  3095. if (p) {
  3096. /* found string, make sure next char is space or zero */
  3097. const int len = strlen(needle);
  3098. if (p[len] == ' ' || p[len] == 0)
  3099. return 1;
  3100. else
  3101. return 0;
  3102. }
  3103. else
  3104. return 0;
  3105. }
  3106. /* Run all the known extension function tests, if the extension is supported.
  3107. * Return a count of how many failed.
  3108. */
  3109. static int
  3110. check_functions( const char *extensions )
  3111. {
  3112. struct name_test_pair *entry;
  3113. int failures = 0, passes = 0, untested = 0;
  3114. int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0;
  3115. int doTests = 0;
  3116. const char *version = (const char *) glGetString(GL_VERSION);
  3117. /* The functions list will have "real" entries (consisting of
  3118. * a GL function name and a pointer to an exercise function for
  3119. * that GL function), and "group" entries (indicated as
  3120. * such by having a "-" as the first character of the name).
  3121. * "Group" names always start with the "-" character, and can
  3122. * be numeric (e.g. "-1.0", "-2.1"), indicating that a particular
  3123. * OpenGL version is required for the following functions; or can be
  3124. * an extension name (e.g. "-GL_ARB_multitexture") that means
  3125. * that the named extension is required for the following functions.
  3126. */
  3127. for (entry = functions; entry->name; entry++) {
  3128. /* Check if this is a group indicator */
  3129. if (entry->name[0] == '-') {
  3130. /* A group indicator; check if it's an OpenGL version group */
  3131. if (entry->name[1] == '1') {
  3132. /* check GL version 1.x */
  3133. if (version[0] == '1' &&
  3134. version[1] == '.' &&
  3135. version[2] >= entry->name[3])
  3136. doTests = 1;
  3137. else
  3138. doTests = 0;
  3139. }
  3140. else if (entry->name[1] == '2') {
  3141. if (version[0] == '2' &&
  3142. version[1] == '.' &&
  3143. version[2] >= entry->name[3])
  3144. doTests = 1;
  3145. else
  3146. doTests = 0;
  3147. }
  3148. else {
  3149. /* check if the named extension is available */
  3150. doTests = extension_supported(extensions, entry->name+1);
  3151. }
  3152. /* doTests is now set if we're starting an OpenGL version
  3153. * group, and the running OpenGL version is at least the
  3154. * version required; or if we're starting an OpenGL extension
  3155. * group, and the extension is supported.
  3156. */
  3157. if (doTests)
  3158. printf("Testing %s functions\n", entry->name + 1);
  3159. /* Each time we hit a title function, reset the function
  3160. * counts.
  3161. */
  3162. failures = 0;
  3163. passes = 0;
  3164. untested = 0;
  3165. }
  3166. else if (doTests) {
  3167. /* Here, we know we're trying to exercise a function for
  3168. * a supported extension. See whether we have a test for
  3169. * it, and try to run it.
  3170. */
  3171. generic_func funcPtr = (generic_func) glXGetProcAddressARB((const GLubyte *) entry->name);
  3172. if (funcPtr) {
  3173. if (entry->test) {
  3174. GLboolean b;
  3175. printf(" Validating %s:", entry->name);
  3176. b = (*entry->test)(funcPtr);
  3177. if (b) {
  3178. printf(" Pass\n");
  3179. passes++;
  3180. totalPass++;
  3181. }
  3182. else {
  3183. printf(" FAIL!!!\n");
  3184. failures++;
  3185. totalFail++;
  3186. }
  3187. }
  3188. else {
  3189. untested++;
  3190. totalUntested++;
  3191. }
  3192. }
  3193. else {
  3194. printf(" glXGetProcAddress(%s) failed!\n", entry->name);
  3195. failures++;
  3196. totalFail++;
  3197. }
  3198. }
  3199. else {
  3200. /* Here, we have a function that belongs to a group that
  3201. * is known to be unsupported.
  3202. */
  3203. totalUnsupported++;
  3204. }
  3205. /* Make sure a poor test case doesn't leave any lingering
  3206. * OpenGL errors.
  3207. */
  3208. CheckGLError(__LINE__, __FILE__, __FUNCTION__);
  3209. if (doTests && (!(entry+1)->name || (entry+1)->name[0] == '-')) {
  3210. if (failures > 0) {
  3211. printf(" %d failed.\n", failures);
  3212. }
  3213. if (passes > 0) {
  3214. printf(" %d passed.\n", passes);
  3215. }
  3216. if (untested > 0) {
  3217. printf(" %d untested.\n", untested);
  3218. }
  3219. }
  3220. }
  3221. printf("-----------------------------\n");
  3222. printf("Total: %d pass %d fail %d untested %d unsupported %d total\n",
  3223. totalPass, totalFail, totalUntested, totalUnsupported,
  3224. totalPass + totalFail + totalUntested + totalUnsupported);
  3225. return totalFail;
  3226. }
  3227. /* Return an error code */
  3228. #define ERROR_NONE 0
  3229. #define ERROR_NO_VISUAL 1
  3230. #define ERROR_NO_CONTEXT 2
  3231. #define ERROR_NO_MAKECURRENT 3
  3232. #define ERROR_FAILED 4
  3233. static int
  3234. print_screen_info(Display *dpy, int scrnum, Bool allowDirect)
  3235. {
  3236. Window win;
  3237. int attribSingle[] = {
  3238. GLX_RGBA,
  3239. GLX_RED_SIZE, 1,
  3240. GLX_GREEN_SIZE, 1,
  3241. GLX_BLUE_SIZE, 1,
  3242. GLX_STENCIL_SIZE, 1,
  3243. None };
  3244. int attribDouble[] = {
  3245. GLX_RGBA,
  3246. GLX_RED_SIZE, 1,
  3247. GLX_GREEN_SIZE, 1,
  3248. GLX_BLUE_SIZE, 1,
  3249. GLX_STENCIL_SIZE, 1,
  3250. GLX_DOUBLEBUFFER,
  3251. None };
  3252. XSetWindowAttributes attr;
  3253. unsigned long mask;
  3254. Window root;
  3255. GLXContext ctx;
  3256. XVisualInfo *visinfo;
  3257. int width = 100, height = 100;
  3258. int failures;
  3259. root = RootWindow(dpy, scrnum);
  3260. visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
  3261. if (!visinfo) {
  3262. visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
  3263. if (!visinfo) {
  3264. fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
  3265. return ERROR_NO_VISUAL;
  3266. }
  3267. }
  3268. attr.background_pixel = 0;
  3269. attr.border_pixel = 0;
  3270. attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone);
  3271. attr.event_mask = StructureNotifyMask | ExposureMask;
  3272. mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
  3273. win = XCreateWindow(dpy, root, 0, 0, width, height,
  3274. 0, visinfo->depth, InputOutput,
  3275. visinfo->visual, mask, &attr);
  3276. ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
  3277. if (!ctx) {
  3278. fprintf(stderr, "Error: glXCreateContext failed\n");
  3279. XDestroyWindow(dpy, win);
  3280. return ERROR_NO_CONTEXT;
  3281. }
  3282. if (!glXMakeCurrent(dpy, win, ctx)) {
  3283. fprintf(stderr, "Error: glXMakeCurrent failed\n");
  3284. glXDestroyContext(dpy, ctx);
  3285. XDestroyWindow(dpy, win);
  3286. return ERROR_NO_MAKECURRENT;
  3287. }
  3288. failures = check_functions( (const char *) glGetString(GL_EXTENSIONS) );
  3289. glXDestroyContext(dpy, ctx);
  3290. XDestroyWindow(dpy, win);
  3291. return (failures == 0 ? ERROR_NONE : ERROR_FAILED);
  3292. }
  3293. int
  3294. main(int argc, char *argv[])
  3295. {
  3296. char *displayName = NULL;
  3297. Display *dpy;
  3298. int returnCode;
  3299. dpy = XOpenDisplay(displayName);
  3300. if (!dpy) {
  3301. fprintf(stderr, "Error: unable to open display %s\n", displayName);
  3302. return -1;
  3303. }
  3304. returnCode = print_screen_info(dpy, 0, GL_TRUE);
  3305. XCloseDisplay(dpy);
  3306. return returnCode;
  3307. }