3dinterface.cpp 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736
  1. /*
  2. 3D interface - interface pro OpenGL
  3. */
  4. #include "3d_all.h"
  5. int glstav_blending; // blending on-off
  6. int glstav_cull; // cull mod
  7. int glstav_cull_mod; // jaka strana se orezava
  8. int glstav_lighting; // gl svetla
  9. int glstav_specular; // spekularni svetla
  10. int glstav_diffuse; // diffusni svetla
  11. int glstav_mlha;
  12. int glstav_mlha_causal;
  13. int glstav_array_diffuse;
  14. int glstav_array_specular;
  15. int glstav_array_normal;
  16. int glstav_genenv_s[6]; // 1
  17. int glstav_genenv_t[6]; // 2
  18. int glstav_genenv_r[6]; // 3
  19. int glstav_genenv_q[6]; // 4
  20. int glstav_multitext_units;
  21. int glstav_alfa_blok;
  22. int glstav_text_blok[6];
  23. int glstav_num_bumb_units;
  24. int *glstav_p_bumb_units;
  25. int glstav_cliping;
  26. int glstav_pn_triangles;
  27. int glstav_deph_test;
  28. int glstav_alfa_test;
  29. int glstav_zmask;
  30. int glstav_bump_mapping;
  31. int glstav_zmena_kamery;
  32. int glstav_text_akt; // aktivni texury
  33. int glstav_text_akt_client; // aktivni klientska texura
  34. int glstav_textury_2d[6]; // textury
  35. int glstav_textury_1d[6]; // textury
  36. GLuint glstav_last_text_2d[6]; // posledni textura
  37. GLuint glstav_last_text_1d[6]; // posledni textura
  38. int glstav_text_array[6]; // texturovaci pole
  39. int glstav_text_array_akt; // aktualni texturovaci pole
  40. int glstav_text_map_indicie[6]; // mapovaci indicie pro textury (cislo mapy)
  41. int glstav_text_poly_indicie; // mapovaci indicie pro poly (cislo mapy)
  42. int glstav_posun_flagy2[6] =
  43. { MAT2_T1_MATRIX, MAT2_T2_MATRIX, MAT2_T3_MATRIX, MAT2_T4_MATRIX, 0, 0 };
  44. int glstav_texgen_on[6] =
  45. { MAT2_CALC_MAP1, MAT2_CALC_MAP2, MAT2_CALC_MAP3, MAT2_CALC_MAP4, 0, 0 };
  46. int glstav_texgen_eye_lin_flagy[6] =
  47. { MAT_T1_EYE_LIN, MAT_T2_EYE_LIN, MAT_T3_EYE_LIN, MAT_T4_EYE_LIN, 0, 0 };
  48. int glstav_texgen_sphere_flagy[6] =
  49. { MAT_T1_SPHERE, MAT_T2_SPHERE, MAT_T3_SPHERE, MAT_T4_SPHERE, 0, 0 };
  50. GLMATRIX glstav_texgen[6];
  51. int glstav_view_x;
  52. int glstav_view_y;
  53. int glstav_view_dx;
  54. int glstav_view_dy;
  55. int glstav_matrix_2d_mod;
  56. GLenum arb_prevodni_tabulka[6] = { GL_TEXTURE0_ARB,
  57. GL_TEXTURE1_ARB,
  58. GL_TEXTURE2_ARB,
  59. GL_TEXTURE3_ARB,
  60. GL_TEXTURE4_ARB,
  61. GL_TEXTURE5_ARB
  62. };
  63. STAGE_FUNC_ALFA p_alfa_stage_func[STAGE_ALFA_FUNKCI];
  64. STAGE_FUNC p_text_stage_func[STAGE_TEXT_FUNKCI];
  65. STAGE_FUNC_ELEM p_text_stage_func_elem[STAGE_TEXT_FUNKCI];
  66. EDIT_STATE_ALFA_BLOK alfa_stage_edit_blok[STAGE_ALFA_FUNKCI +
  67. STATE_BLOK_PRUHL + 1];
  68. EDIT_STATE_TEXT_BLOK text_stage_edit_blok[STAGE_TEXT_FUNKCI];
  69. #define TYP_TEXTURY_NUM 3
  70. #define TYP_TEXT_COLOR 0
  71. #define TYP_TEXT_DOT3 1
  72. #define TYP_TEXT_DUDV 2
  73. char typ_textury[TYP_TEXTURY_NUM][MAX_JMENO] =
  74. { "Color Map", "DOT3 Bump-Map", "DUDV Map" };
  75. GLMATRIX __mat_kamera;
  76. GLMATRIX __mat_world;
  77. GLMATRIX __mat_vysl;
  78. GLMATRIX __mat_camera_project; // transformuje 3D do 2D
  79. GLMATRIX __mat_init;
  80. GLMATRIX __mat_top_matrix[MAX_WORD_MATRIX_STACK]; // druha word-matrix -> top-matrix
  81. int __mat_top_matrix_akt;
  82. GLMATRIX __mat_tmp;
  83. int __mat_text[4];
  84. void glstav_reset(void)
  85. {
  86. int i;
  87. glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &glstav_multitext_units);
  88. glstav_bump_mapping = TRUE;
  89. glstav_cull = FALSE;
  90. glstav_cull_mod = K_CHYBA;
  91. cull_on();
  92. cull_back();
  93. glstav_lighting = TRUE;
  94. light_on_off(FALSE);
  95. glstav_specular = TRUE;
  96. specular_off();
  97. glstav_diffuse = FALSE;
  98. glstav_mlha = TRUE;
  99. glstav_mlha_causal = FALSE;
  100. disable_fog();
  101. glstav_blending = TRUE;
  102. blend_off();
  103. glstav_deph_test = FALSE;
  104. deph_test_set(TRUE);
  105. glstav_alfa_test = TRUE;
  106. alfa_test_off();
  107. glAlphaFunc(GL_GREATER, 0.5f);
  108. glstav_zmask = FALSE;
  109. zmask_set(TRUE);
  110. glstav_array_diffuse = FALSE;
  111. glstav_array_specular = FALSE;
  112. glstav_array_normal = FALSE;
  113. for (i = 0; i < 6; i++) {
  114. glstav_genenv_s[i] = FALSE;
  115. glstav_genenv_t[i] = FALSE;
  116. glstav_genenv_r[i] = FALSE;
  117. glstav_genenv_q[i] = FALSE;
  118. glstav_text_blok[i] = K_CHYBA;
  119. glstav_textury_1d[i] = FALSE;
  120. glstav_textury_2d[i] = FALSE;
  121. glstav_last_text_1d[i] = FALSE;
  122. glstav_last_text_2d[i] = FALSE;
  123. glstav_text_array[i] = FALSE;
  124. glstav_text_map_indicie[i] = FALSE;
  125. }
  126. glstav_alfa_blok = K_CHYBA;
  127. glstav_text_array_akt = K_CHYBA;
  128. glstav_text_poly_indicie = K_CHYBA;
  129. glstav_text_akt = K_CHYBA;
  130. glstav_text_akt_client = FALSE;
  131. glstav_pn_triangles = FALSE;
  132. }
  133. /* Elementarni nastavovaci funkce
  134. */
  135. void el_text_modulace(void)
  136. {
  137. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  138. }
  139. void el_text_modulace_comb(void)
  140. {
  141. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
  142. glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
  143. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
  144. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
  145. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
  146. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
  147. }
  148. void el_text_modulace_2x_comb(void)
  149. {
  150. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
  151. glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
  152. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
  153. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
  154. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
  155. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
  156. glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, 2.0f);
  157. }
  158. void el_text_add(void)
  159. {
  160. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
  161. }
  162. void el_text_add_comb(void)
  163. {
  164. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
  165. glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
  166. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
  167. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
  168. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
  169. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
  170. }
  171. void el_text_decal(void)
  172. {
  173. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  174. }
  175. void el_text_blend(void)
  176. {
  177. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
  178. }
  179. void el_text_replace(void)
  180. {
  181. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
  182. }
  183. void el_text_dot3_bump(void)
  184. {
  185. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
  186. glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT);
  187. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
  188. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
  189. glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
  190. glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
  191. }
  192. /* Stage-blok-sekce
  193. */
  194. int sbl_text_modulace(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  195. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  196. {
  197. EDIT_TEXT *p_txt;
  198. int t, ret = last_text + 1;
  199. int koord;
  200. glstav_multitext_units -= rezerva;
  201. if (text_set_num(last_text)) { // cislo textury
  202. t = p_text->textury[0];
  203. p_txt = p_mat->p_text[t];
  204. if (p_txt) {
  205. text_on(p_txt->typ);
  206. text_set(p_txt->text, p_txt->typ);
  207. text_set_blok(last_text, BLOK_MODULACE);
  208. koord = p_text->text_koord[t];
  209. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  210. set_matrix_texture(last_text, p_mat->ttext + koord);
  211. }
  212. else {
  213. ret_matrix_texture(last_text);
  214. }
  215. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  216. texgen_env_on(last_text);
  217. glstav_text_map_indicie[last_text] = K_CHYBA;
  218. }
  219. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  220. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  221. p_mat->texgen_koord_t[koord]);
  222. glstav_text_map_indicie[last_text] = K_CHYBA;
  223. }
  224. else {
  225. texgen_off(last_text);
  226. glstav_text_map_indicie[last_text] = koord;
  227. }
  228. }
  229. else {
  230. ret = last_text;
  231. }
  232. }
  233. else {
  234. ret = K_CHYBA;
  235. }
  236. glstav_multitext_units += rezerva;
  237. return (ret);
  238. }
  239. int sbl_text_modulace_2x(EDIT_MATERIAL * p_mat,
  240. EDIT_STATE_TEXT_BLOK * p_stage, MATERIAL_TEXT_OLD * p_text, int last_text,
  241. int rezerva)
  242. {
  243. EDIT_TEXT *p_txt;
  244. int t, ret = last_text + 1;
  245. int koord;
  246. glstav_multitext_units -= rezerva;
  247. if (text_set_num(last_text)) { // cislo textury
  248. t = p_text->textury[0];
  249. p_txt = p_mat->p_text[t];
  250. if (p_txt) {
  251. text_on(p_txt->typ);
  252. text_set(p_txt->text, p_txt->typ);
  253. text_set_blok(last_text, BLOK_MODULACE);
  254. koord = p_text->text_koord[t];
  255. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  256. set_matrix_texture(last_text, p_mat->ttext + koord);
  257. }
  258. else {
  259. ret_matrix_texture(last_text);
  260. }
  261. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  262. texgen_env_on(last_text);
  263. glstav_text_map_indicie[last_text] = K_CHYBA;
  264. }
  265. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  266. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  267. p_mat->texgen_koord_t[koord]);
  268. glstav_text_map_indicie[last_text] = K_CHYBA;
  269. }
  270. else {
  271. texgen_off(last_text);
  272. glstav_text_map_indicie[last_text] = koord;
  273. }
  274. }
  275. else {
  276. ret = last_text;
  277. }
  278. }
  279. else {
  280. ret = K_CHYBA;
  281. }
  282. glstav_multitext_units += rezerva;
  283. return (ret);
  284. }
  285. int sbl_text_add(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  286. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  287. {
  288. EDIT_TEXT *p_txt;
  289. int t, ret = last_text + 1;
  290. int koord;
  291. glstav_multitext_units -= rezerva;
  292. if (text_set_num(last_text)) { // cislo textury
  293. t = p_text->textury[0];
  294. p_txt = p_mat->p_text[t];
  295. if (p_mat->textfile[t][0] && p_mat->p_text[t]) {
  296. text_on(p_txt->typ);
  297. text_set(p_txt->text, p_txt->typ);
  298. text_set_blok(last_text, BLOK_ADD);
  299. koord = p_text->text_koord[t];
  300. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  301. set_matrix_texture(last_text, p_mat->ttext + koord);
  302. }
  303. else {
  304. ret_matrix_texture(last_text);
  305. }
  306. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  307. texgen_env_on(last_text);
  308. glstav_text_map_indicie[last_text] = K_CHYBA;
  309. }
  310. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  311. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  312. p_mat->texgen_koord_t[koord]);
  313. glstav_text_map_indicie[last_text] = K_CHYBA;
  314. }
  315. else {
  316. texgen_off(last_text);
  317. glstav_text_map_indicie[last_text] = koord;
  318. }
  319. }
  320. else {
  321. ret = last_text;
  322. }
  323. }
  324. else {
  325. ret = K_CHYBA;
  326. }
  327. glstav_multitext_units += rezerva;
  328. return (ret);
  329. }
  330. int sbl_text_decal(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  331. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  332. {
  333. EDIT_TEXT *p_txt;
  334. int t, ret = last_text + 1;
  335. int koord;
  336. glstav_multitext_units -= rezerva;
  337. if (text_set_num(last_text)) { // cislo textury
  338. t = p_text->textury[0];
  339. p_txt = p_mat->p_text[t];
  340. if (p_mat->textfile[t][0] && p_mat->p_text[t]) {
  341. text_on(p_txt->typ);
  342. text_set(p_txt->text, p_txt->typ);
  343. text_set_blok(last_text, BLOK_DECAL);
  344. koord = p_text->text_koord[t];
  345. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  346. set_matrix_texture(last_text, p_mat->ttext + koord);
  347. }
  348. else {
  349. ret_matrix_texture(last_text);
  350. }
  351. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  352. texgen_env_on(last_text);
  353. glstav_text_map_indicie[last_text] = K_CHYBA;
  354. }
  355. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  356. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  357. p_mat->texgen_koord_t[koord]);
  358. glstav_text_map_indicie[last_text] = K_CHYBA;
  359. }
  360. else {
  361. texgen_off(last_text);
  362. glstav_text_map_indicie[last_text] = koord;
  363. }
  364. }
  365. else {
  366. ret = last_text;
  367. }
  368. }
  369. else {
  370. ret = K_CHYBA;
  371. }
  372. glstav_multitext_units += rezerva;
  373. return (ret);
  374. }
  375. int sbl_text_blend(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  376. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  377. {
  378. EDIT_TEXT *p_txt;
  379. int t, ret = last_text + 1;
  380. int koord;
  381. glstav_multitext_units -= rezerva;
  382. if (text_set_num(last_text)) { // cislo textury
  383. t = p_text->textury[0];
  384. p_txt = p_mat->p_text[t];
  385. if (p_mat->textfile[t][0] && p_mat->p_text[t]) {
  386. text_on(p_txt->typ);
  387. text_set(p_txt->text, p_txt->typ);
  388. text_set_blok(last_text, BLOK_BLEND);
  389. koord = p_text->text_koord[t];
  390. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  391. set_matrix_texture(last_text, p_mat->ttext + koord);
  392. }
  393. else {
  394. ret_matrix_texture(last_text);
  395. }
  396. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  397. texgen_env_on(last_text);
  398. glstav_text_map_indicie[last_text] = K_CHYBA;
  399. }
  400. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  401. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  402. p_mat->texgen_koord_t[koord]);
  403. glstav_text_map_indicie[last_text] = K_CHYBA;
  404. }
  405. else {
  406. texgen_off(last_text);
  407. glstav_text_map_indicie[last_text] = koord;
  408. }
  409. }
  410. else {
  411. ret = last_text;
  412. }
  413. }
  414. else {
  415. ret = K_CHYBA;
  416. }
  417. glstav_multitext_units += rezerva;
  418. return (ret);
  419. }
  420. int sbl_text_replace(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  421. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  422. {
  423. EDIT_TEXT *p_txt;
  424. int t, ret = last_text + 1;
  425. int koord;
  426. glstav_multitext_units -= rezerva;
  427. if (text_set_num(last_text)) { // cislo textury
  428. t = p_text->textury[0];
  429. p_txt = p_mat->p_text[t];
  430. if (p_mat->textfile[t][0] && p_mat->p_text[t]) {
  431. text_on(p_txt->typ);
  432. text_set(p_txt->text, p_txt->typ);
  433. text_set_blok(last_text, BLOK_REPLACE);
  434. koord = p_text->text_koord[t];
  435. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  436. set_matrix_texture(last_text, p_mat->ttext + koord);
  437. }
  438. else {
  439. ret_matrix_texture(last_text);
  440. }
  441. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  442. texgen_env_on(last_text);
  443. glstav_text_map_indicie[last_text] = K_CHYBA;
  444. }
  445. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  446. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  447. p_mat->texgen_koord_t[koord]);
  448. glstav_text_map_indicie[last_text] = K_CHYBA;
  449. }
  450. else {
  451. texgen_off(last_text);
  452. glstav_text_map_indicie[last_text] = koord;
  453. }
  454. }
  455. else {
  456. ret = last_text;
  457. }
  458. }
  459. else {
  460. ret = K_CHYBA;
  461. }
  462. glstav_multitext_units += rezerva;
  463. return (ret);
  464. }
  465. int sbl_text_dot3_bump(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  466. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  467. {
  468. EDIT_TEXT *p_txt;
  469. int t, ret;
  470. int koord;
  471. /* Test efektu - je to podporovane videokartou?
  472. */
  473. glstav_multitext_units -= rezerva;
  474. if (gl_ext::extlist_text_env_dot3
  475. && last_text + p_stage->textur <= glstav_multitext_units) {
  476. t = p_text->textury[DOT3_BUMP]; // Text 0 - DOT3
  477. p_txt = p_mat->p_text[t];
  478. if (p_mat->p_text[t]) {
  479. text_set_num(last_text);
  480. text_on(p_txt->typ);
  481. text_set(p_txt->text, p_txt->typ);
  482. text_set_blok(last_text, BLOK_DOT3_BUMP);
  483. koord = p_text->text_koord[t];
  484. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  485. set_matrix_texture(last_text, p_mat->ttext + koord);
  486. }
  487. else {
  488. ret_matrix_texture(last_text);
  489. }
  490. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  491. texgen_env_on(last_text);
  492. glstav_text_map_indicie[last_text] = K_CHYBA;
  493. }
  494. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  495. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  496. p_mat->texgen_koord_t[koord]);
  497. glstav_text_map_indicie[last_text] = K_CHYBA;
  498. }
  499. else {
  500. texgen_off(last_text);
  501. glstav_text_map_indicie[last_text] = koord;
  502. }
  503. }
  504. last_text++;
  505. }
  506. if (last_text < glstav_multitext_units) {
  507. t = p_text->textury[DOT3_TEXT]; // Text 1 - Color-mapa
  508. p_txt = p_mat->p_text[t];
  509. if (p_mat->p_text[t]) {
  510. text_set_num(last_text);
  511. text_on(p_txt->typ);
  512. text_set(p_txt->text, p_txt->typ);
  513. text_set_blok(last_text, p_text->text_funkce[DOT3_TEXT]);
  514. koord = p_text->text_koord[t];
  515. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  516. set_matrix_texture(last_text, p_mat->ttext + koord);
  517. }
  518. else {
  519. ret_matrix_texture(last_text);
  520. }
  521. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  522. texgen_env_on(last_text);
  523. glstav_text_map_indicie[last_text] = K_CHYBA;
  524. }
  525. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  526. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  527. p_mat->texgen_koord_t[koord]);
  528. glstav_text_map_indicie[last_text] = K_CHYBA;
  529. }
  530. else {
  531. texgen_off(last_text);
  532. glstav_text_map_indicie[last_text] = koord;
  533. }
  534. }
  535. last_text++;
  536. ret = last_text;
  537. }
  538. else {
  539. ret = K_CHYBA;
  540. }
  541. glstav_multitext_units += rezerva;
  542. return (ret);
  543. }
  544. int sbl_text_dot3_bump_env(EDIT_MATERIAL * p_mat,
  545. EDIT_STATE_TEXT_BLOK * p_stage, MATERIAL_TEXT_OLD * p_text, int last_text,
  546. int rezerva)
  547. {
  548. EDIT_TEXT *p_txt;
  549. int t, ret;
  550. int koord;
  551. /* Test efektu - je to podporovane videokartou?
  552. */
  553. glstav_multitext_units -= rezerva;
  554. if (gl_ext::extlist_text_env_dot3
  555. && last_text + p_stage->textur <= glstav_multitext_units) {
  556. t = p_text->textury[DOT3_ENV]; // Text 2 - Lightmapa
  557. p_txt = p_mat->p_text[t];
  558. if (p_mat->p_text[t]) {
  559. text_set_num(last_text);
  560. text_on(p_txt->typ);
  561. text_set(p_txt->text, p_txt->typ);
  562. text_set_blok(last_text, p_text->text_funkce[DOT3_ENV]);
  563. koord = p_text->text_koord[t];
  564. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  565. set_matrix_texture(last_text, p_mat->ttext + koord);
  566. }
  567. else {
  568. ret_matrix_texture(last_text);
  569. }
  570. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  571. texgen_env_on(last_text);
  572. glstav_text_map_indicie[last_text] = K_CHYBA;
  573. }
  574. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  575. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  576. p_mat->texgen_koord_t[koord]);
  577. glstav_text_map_indicie[last_text] = K_CHYBA;
  578. }
  579. else {
  580. texgen_off(last_text);
  581. glstav_text_map_indicie[last_text] = koord;
  582. }
  583. }
  584. last_text++;
  585. t = p_text->textury[DOT3_BUMP]; // Text 0 - DOT3 Color-Mapa
  586. p_txt = p_mat->p_text[t];
  587. if (p_mat->p_text[t]) {
  588. text_set_num(last_text);
  589. text_on(p_txt->typ);
  590. text_set(p_txt->text, p_txt->typ);
  591. text_set_blok(last_text, BLOK_DOT3_BUMP);
  592. koord = p_text->text_koord[t];
  593. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  594. set_matrix_texture(last_text, p_mat->ttext + koord);
  595. }
  596. else {
  597. ret_matrix_texture(last_text);
  598. }
  599. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  600. texgen_env_on(last_text);
  601. glstav_text_map_indicie[last_text] = K_CHYBA;
  602. }
  603. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  604. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  605. p_mat->texgen_koord_t[koord]);
  606. glstav_text_map_indicie[last_text] = K_CHYBA;
  607. }
  608. else {
  609. texgen_off(last_text);
  610. glstav_text_map_indicie[last_text] = koord;
  611. }
  612. }
  613. last_text++;
  614. }
  615. if (last_text < glstav_multitext_units) {
  616. t = p_text->textury[DOT3_TEXT]; // Text 1 - Color-mapa
  617. p_txt = p_mat->p_text[t];
  618. if (p_mat->p_text[t]) {
  619. text_set_num(last_text);
  620. text_on(p_txt->typ);
  621. text_set(p_txt->text, p_txt->typ);
  622. text_set_blok(last_text, p_text->text_funkce[DOT3_TEXT]);
  623. koord = p_text->text_koord[t];
  624. if (p_mat->flag2 & glstav_posun_flagy2[koord]) {
  625. set_matrix_texture(last_text, p_mat->ttext + koord);
  626. }
  627. else {
  628. ret_matrix_texture(last_text);
  629. }
  630. if (p_mat->flag & glstav_texgen_sphere_flagy[koord]) {
  631. texgen_env_on(last_text);
  632. glstav_text_map_indicie[last_text] = K_CHYBA;
  633. }
  634. else if (p_mat->flag & glstav_texgen_eye_lin_flagy[koord]) {
  635. texgen_linear_eye_2d_on(last_text, p_mat->texgen_koord_s[koord],
  636. p_mat->texgen_koord_t[koord]);
  637. glstav_text_map_indicie[last_text] = K_CHYBA;
  638. }
  639. else {
  640. texgen_off(last_text);
  641. glstav_text_map_indicie[last_text] = koord;
  642. }
  643. }
  644. last_text++;
  645. ret = last_text;
  646. }
  647. else {
  648. ret = K_CHYBA;
  649. }
  650. glstav_multitext_units += rezerva;
  651. return (ret);
  652. }
  653. int sbl_text_bump_env(EDIT_MATERIAL * p_mat, EDIT_STATE_TEXT_BLOK * p_stage,
  654. MATERIAL_TEXT_OLD * p_text, int last_text, int rezerva)
  655. {
  656. return (K_CHYBA);
  657. }
  658. /* Alfa-stage bloky
  659. */
  660. void sbl_alfa_default(void)
  661. {
  662. blend_off();
  663. alfa_test_off();
  664. }
  665. void sbl_alfa_flek(void)
  666. {
  667. blend_on();
  668. alfa_test_off();
  669. glBlendFunc(GL_ZERO, GL_SRC_COLOR);
  670. }
  671. void sbl_alfa_kour(void)
  672. {
  673. blend_on();
  674. alfa_test_off();
  675. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR);
  676. }
  677. void sbl_alfa_pruhledny(void)
  678. {
  679. blend_on();
  680. alfa_test_on();
  681. glAlphaFunc(GL_GREATER, 0.004f);
  682. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  683. }
  684. void sbl_alfa_test(void)
  685. {
  686. blend_off();
  687. alfa_test_on();
  688. glAlphaFunc(GL_GREATER, 0.5f);
  689. }
  690. void nahod_state_bloky(void)
  691. {
  692. /* Text-bloky
  693. */
  694. p_text_stage_func[0] = sbl_text_modulace;
  695. p_text_stage_func[1] = sbl_text_add;
  696. p_text_stage_func[2] = sbl_text_decal;
  697. p_text_stage_func[3] = sbl_text_blend;
  698. p_text_stage_func[4] = sbl_text_replace;
  699. p_text_stage_func[5] = sbl_text_dot3_bump;
  700. p_text_stage_func[6] = sbl_text_dot3_bump_env;
  701. p_text_stage_func[7] = sbl_text_bump_env;
  702. p_text_stage_func[8] = sbl_text_modulace_2x;
  703. /* Elementarni text_bloky funkce
  704. */
  705. p_text_stage_func_elem[0] = el_text_modulace;
  706. p_text_stage_func_elem[1] = el_text_add;
  707. p_text_stage_func_elem[2] = el_text_decal;
  708. p_text_stage_func_elem[3] = el_text_blend;
  709. p_text_stage_func_elem[4] = el_text_replace;
  710. p_text_stage_func_elem[5] = el_text_dot3_bump;
  711. p_text_stage_func_elem[6] = el_text_modulace_2x_comb;
  712. /* Alfa-bloky
  713. */
  714. p_alfa_stage_func[0] = sbl_alfa_default;
  715. p_alfa_stage_func[1] = sbl_alfa_flek;
  716. p_alfa_stage_func[2] = sbl_alfa_kour;
  717. p_alfa_stage_func[3] = sbl_alfa_pruhledny;
  718. p_alfa_stage_func[4] = sbl_alfa_test;
  719. /* Text-bloky
  720. */
  721. strcpy(text_stage_edit_blok[0].jmeno, "Modulace");
  722. text_stage_edit_blok[0].funkce = 0;
  723. text_stage_edit_blok[0].edit_funkce = -1;
  724. text_stage_edit_blok[0].textur = 1;
  725. text_stage_edit_blok[0].delka = 1;
  726. text_stage_edit_blok[0].textury_typ[0] = TYP_TEXT_COLOR;
  727. text_stage_edit_blok[0].text_funkce[0] = BLOK_MODULACE;
  728. strcpy(text_stage_edit_blok[1].jmeno, "Add");
  729. text_stage_edit_blok[1].funkce = 1;
  730. text_stage_edit_blok[1].edit_funkce = -1;
  731. text_stage_edit_blok[1].textur = 1;
  732. text_stage_edit_blok[1].delka = 1;
  733. text_stage_edit_blok[1].textury_typ[0] = TYP_TEXT_COLOR;
  734. text_stage_edit_blok[1].text_funkce[0] = BLOK_ADD;
  735. strcpy(text_stage_edit_blok[2].jmeno, "Decal");
  736. text_stage_edit_blok[2].funkce = 2;
  737. text_stage_edit_blok[2].edit_funkce = -1;
  738. text_stage_edit_blok[2].textur = 1;
  739. text_stage_edit_blok[2].delka = 1;
  740. text_stage_edit_blok[2].textury_typ[0] = TYP_TEXT_COLOR;
  741. text_stage_edit_blok[2].text_funkce[0] = BLOK_DECAL;
  742. strcpy(text_stage_edit_blok[3].jmeno, "Blend");
  743. text_stage_edit_blok[3].funkce = 3;
  744. text_stage_edit_blok[3].edit_funkce = -1;
  745. text_stage_edit_blok[3].textur = 1;
  746. text_stage_edit_blok[3].delka = 1;
  747. text_stage_edit_blok[3].textury_typ[0] = TYP_TEXT_COLOR;
  748. text_stage_edit_blok[3].text_funkce[0] = BLOK_BLEND;
  749. strcpy(text_stage_edit_blok[4].jmeno, "Replace");
  750. text_stage_edit_blok[4].funkce = 4;
  751. text_stage_edit_blok[4].edit_funkce = -1;
  752. text_stage_edit_blok[4].textur = 1;
  753. text_stage_edit_blok[4].delka = 1;
  754. text_stage_edit_blok[4].textury_typ[0] = TYP_TEXT_COLOR;
  755. text_stage_edit_blok[4].text_funkce[0] = BLOK_REPLACE;
  756. strcpy(text_stage_edit_blok[5].jmeno, "DOT3Color");
  757. text_stage_edit_blok[5].funkce = 5;
  758. text_stage_edit_blok[5].edit_funkce = 0;
  759. text_stage_edit_blok[5].textur = 2;
  760. text_stage_edit_blok[5].delka = 2;
  761. text_stage_edit_blok[5].textury_typ[0] = TYP_TEXT_DOT3; // dot-3 bump-mapa
  762. text_stage_edit_blok[5].textury_typ[1] = TYP_TEXT_COLOR; // color-mapa
  763. text_stage_edit_blok[5].text_funkce[0] = BLOK_DOT3_BUMP;
  764. text_stage_edit_blok[5].text_funkce[1] = BLOK_MODULACE;
  765. strcpy(text_stage_edit_blok[6].jmeno, "DOT3ENV");
  766. text_stage_edit_blok[6].funkce = 6;
  767. text_stage_edit_blok[6].edit_funkce = 1;
  768. text_stage_edit_blok[6].textur = 3;
  769. text_stage_edit_blok[6].delka = 3;
  770. text_stage_edit_blok[6].textury_typ[0] = TYP_TEXT_DOT3; // bump-mapa
  771. text_stage_edit_blok[6].textury_typ[1] = TYP_TEXT_COLOR; // color-map textura
  772. text_stage_edit_blok[6].textury_typ[2] = TYP_TEXT_COLOR; // light-mapa
  773. text_stage_edit_blok[6].text_funkce[0] = BLOK_DOT3_BUMP;
  774. text_stage_edit_blok[6].text_funkce[1] = BLOK_MODULACE;
  775. text_stage_edit_blok[6].text_funkce[2] = BLOK_MODULACE;
  776. strcpy(text_stage_edit_blok[7].jmeno, "EnvBump");
  777. text_stage_edit_blok[7].funkce = 7;
  778. text_stage_edit_blok[7].edit_funkce = 2;
  779. text_stage_edit_blok[7].textur = 3;
  780. text_stage_edit_blok[7].delka = 3;
  781. text_stage_edit_blok[7].textury_typ[0] = TYP_TEXT_DUDV; // normalova mapa
  782. text_stage_edit_blok[7].textury_typ[1] = TYP_TEXT_COLOR; // color-map textura
  783. text_stage_edit_blok[7].textury_typ[2] = TYP_TEXT_COLOR; // spodni mapa
  784. text_stage_edit_blok[7].text_funkce[0] = BLOK_BUMP_ENV;
  785. text_stage_edit_blok[7].text_funkce[1] = BLOK_MODULACE;
  786. text_stage_edit_blok[7].text_funkce[2] = BLOK_MODULACE;
  787. strcpy(text_stage_edit_blok[8].jmeno, "Modulace 2X");
  788. text_stage_edit_blok[8].funkce = 0;
  789. text_stage_edit_blok[8].edit_funkce = -1;
  790. text_stage_edit_blok[8].textur = 1;
  791. text_stage_edit_blok[8].delka = 1;
  792. text_stage_edit_blok[8].textury_typ[0] = TYP_TEXT_COLOR;
  793. text_stage_edit_blok[8].text_funkce[0] = BLOK_MODULACE2X;
  794. /* Alfa-bloky
  795. */
  796. strcpy(alfa_stage_edit_blok[0].jmeno, "Default");
  797. alfa_stage_edit_blok[0].alfa_pruhledny = FALSE;
  798. alfa_stage_edit_blok[0].funkce = 0;
  799. strcpy(alfa_stage_edit_blok[1].jmeno, "Flek");
  800. alfa_stage_edit_blok[1].alfa_pruhledny = TRUE;
  801. alfa_stage_edit_blok[1].funkce = 1;
  802. strcpy(alfa_stage_edit_blok[2].jmeno, "Kour");
  803. alfa_stage_edit_blok[2].alfa_pruhledny = TRUE;
  804. alfa_stage_edit_blok[2].funkce = 2;
  805. strcpy(alfa_stage_edit_blok[3].jmeno, "Pruhledny");
  806. alfa_stage_edit_blok[3].alfa_pruhledny = TRUE;
  807. alfa_stage_edit_blok[3].funkce = 3;
  808. strcpy(alfa_stage_edit_blok[4].jmeno, "Maska");
  809. alfa_stage_edit_blok[4].alfa_pruhledny = FALSE;
  810. alfa_stage_edit_blok[4].funkce = 4;
  811. strcpy(alfa_stage_edit_blok[STATE_BLOK_PRUHL].jmeno, "Pruhledny-system");
  812. alfa_stage_edit_blok[STATE_BLOK_PRUHL].alfa_pruhledny = FALSE;
  813. alfa_stage_edit_blok[STATE_BLOK_PRUHL].funkce = 3;
  814. }
  815. /* ATI vertex array - set vertex array
  816. */
  817. void mesh_vertex_array_init_ati(GAME_MESH_OLD * p_mesh)
  818. {
  819. VERTEX_ARRAYS *p_varray = &p_mesh->varray;
  820. p_varray->ati_handle =
  821. glNewObjectBufferATI(p_varray->ati_velikost, NULL, GL_DYNAMIC_ATI);
  822. }
  823. void mesh_vertex_array_zrus_ati(GAME_MESH_OLD * p_mesh)
  824. {
  825. VERTEX_ARRAYS *p_varray = &p_mesh->varray;
  826. if (glIsObjectBufferATI(p_varray->ati_handle)) {
  827. glFreeObjectBufferATI(p_varray->ati_handle);
  828. p_varray->ati_handle = 0;
  829. }
  830. }
  831. void mesh_vertex_array_set_ati(GAME_MESH_OLD * p_mesh)
  832. {
  833. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  834. int handle = p_mesh->varray.ati_handle;
  835. int m2flag = p_mesh->p_data->m2flag;
  836. int norm = glstav_pn_triangles
  837. || m2flag & (MAT2_CALC_MAP1 | MAT2_CALC_MAP2 | MAT2_CALC_MAP3 |
  838. MAT2_CALC_MAP4);
  839. glArrayObjectATI(GL_VERTEX_ARRAY, 3, GL_FLOAT, 0, handle,
  840. p_va->ati_start_pos);
  841. array_normal_off();
  842. array_diffuse_off();
  843. array_specular_off();
  844. if (norm) {
  845. array_normal_on();
  846. glArrayObjectATI(GL_NORMAL_ARRAY, 3, GL_FLOAT, 0, handle,
  847. p_va->ati_start_norm);
  848. }
  849. else {
  850. array_normal_off();
  851. }
  852. if (m2flag & MAT2_DIFFUSE) {
  853. array_diffuse_on();
  854. glArrayObjectATI(GL_COLOR_ARRAY, 4, GL_FLOAT, 0, handle,
  855. p_va->ati_start_diff);
  856. }
  857. else {
  858. array_diffuse_off();
  859. }
  860. if (m2flag & (MAT2_SPECULAR | MAT2_ENV_SPEC)
  861. || p_mesh->p_data->kflag & KONT_DRAW_SPEC) {
  862. array_specular_on();
  863. glArrayObjectATI(GL_SECONDARY_COLOR_ARRAY_EXT, 3, GL_FLOAT, 0, handle,
  864. p_va->ati_start_spec);
  865. }
  866. else {
  867. array_specular_off();
  868. }
  869. }
  870. void mesh_vertex_array_set_koord_ati(GAME_MESH_OLD * p_mesh)
  871. {
  872. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  873. int handle = p_mesh->varray.ati_handle;
  874. int *p_int, ind;
  875. p_int = glstav_text_map_indicie;
  876. ind = *p_int++;
  877. ind = K_CHYBA;
  878. array_text_set_num(0);
  879. if (ind != K_CHYBA) {
  880. array_text_on();
  881. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 0, handle,
  882. p_va->ati_start_text[ind]);
  883. }
  884. else {
  885. array_text_off();
  886. }
  887. ind = *p_int++;
  888. ind = K_CHYBA;
  889. if (array_text_set_num(1)) {
  890. if (ind != K_CHYBA) {
  891. array_text_on();
  892. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 0, handle,
  893. p_va->ati_start_text[ind]);
  894. }
  895. else {
  896. array_text_off();
  897. }
  898. }
  899. ind = *p_int++;
  900. ind = K_CHYBA;
  901. if (array_text_set_num(2)) {
  902. if (ind != K_CHYBA) {
  903. array_text_on();
  904. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 0, handle,
  905. p_va->ati_start_text[ind]);
  906. }
  907. else {
  908. array_text_off();
  909. }
  910. }
  911. ind = *p_int++;
  912. ind = K_CHYBA;
  913. if (array_text_set_num(3)) {
  914. if (ind != K_CHYBA) {
  915. array_text_on();
  916. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT, 0, handle,
  917. p_va->ati_start_text[ind]);
  918. }
  919. else {
  920. array_text_off();
  921. }
  922. }
  923. }
  924. void mesh_vertex_array_upload_ati(GAME_MESH_OLD * p_mesh)
  925. {
  926. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  927. int handle = p_mesh->varray.ati_handle;
  928. int vertexu = p_mesh->vertexnum,
  929. k2flag = p_mesh->p_data->k2flag,
  930. m2flag = p_mesh->p_data->m2flag, kflag = p_mesh->p_data->kflag;
  931. int norm = glstav_pn_triangles
  932. || p_mesh->p_data->
  933. m2flag & (MAT2_CALC_MAP1 | MAT2_CALC_MAP2 | MAT2_CALC_MAP3 |
  934. MAT2_CALC_MAP4);
  935. if (k2flag & KONT2_UPDATE_POS)
  936. glUpdateObjectBufferATI(handle, p_va->ati_start_pos,
  937. sizeof(p_mesh->p_vertex_pos[0]) * vertexu, p_mesh->p_vertex_pos,
  938. GL_PRESERVE_ATI);
  939. if (norm && k2flag & KONT2_UPDATE_NORM)
  940. glUpdateObjectBufferATI(handle, p_va->ati_start_norm,
  941. sizeof(p_mesh->p_vertex_norm[0]) * vertexu, p_mesh->p_vertex_norm,
  942. GL_PRESERVE_ATI);
  943. if (k2flag & KONT2_UPDATE_DIFF && m2flag & MAT2_DIFFUSE) {
  944. if (kflag & KONT_DRAW_VODA) {
  945. glUpdateObjectBufferATI(handle, p_va->ati_start_diff,
  946. sizeof(p_mesh->p_vertex_diff_voda[0]) * vertexu,
  947. p_mesh->p_vertex_diff_voda, GL_PRESERVE_ATI);
  948. }
  949. else {
  950. glUpdateObjectBufferATI(handle, p_va->ati_start_diff,
  951. sizeof(p_mesh->p_vertex_diff[0]) * vertexu, p_mesh->p_vertex_diff,
  952. GL_PRESERVE_ATI);
  953. }
  954. }
  955. if (k2flag & KONT2_UPDATE_SPEC) {
  956. if (kflag & KONT_DRAW_VODA) {
  957. glUpdateObjectBufferATI(handle, p_va->ati_start_spec,
  958. sizeof(p_mesh->p_vertex_spec_voda[0]) * vertexu,
  959. p_mesh->p_vertex_spec_voda, GL_PRESERVE_ATI);
  960. }
  961. else {
  962. glUpdateObjectBufferATI(handle, p_va->ati_start_spec,
  963. sizeof(p_mesh->p_vertex_spec[0]) * vertexu, p_mesh->p_vertex_spec,
  964. GL_PRESERVE_ATI);
  965. }
  966. }
  967. if (k2flag & KONT2_UPDATE_TEXT1)
  968. glUpdateObjectBufferATI(handle, p_va->ati_start_text[0],
  969. sizeof(p_mesh->p_vertex_uv1_material[0]) * vertexu,
  970. p_mesh->p_vertex_uv1_material, GL_PRESERVE_ATI);
  971. if (k2flag & KONT2_UPDATE_TEXT2)
  972. glUpdateObjectBufferATI(handle, p_va->ati_start_text[1],
  973. sizeof(p_mesh->p_vertex_uv2_material[0]) * vertexu,
  974. p_mesh->p_vertex_uv2_material, GL_PRESERVE_ATI);
  975. if (k2flag & KONT2_UPDATE_TEXT3)
  976. glUpdateObjectBufferATI(handle, p_va->ati_start_text[2],
  977. sizeof(p_mesh->p_vertex_uv3_material[0]) * vertexu,
  978. p_mesh->p_vertex_uv3_material, GL_PRESERVE_ATI);
  979. if (k2flag & KONT2_UPDATE_TEXT4)
  980. glUpdateObjectBufferATI(handle, p_va->ati_start_text[3],
  981. sizeof(p_mesh->p_vertex_uv4_material[0]) * vertexu,
  982. p_mesh->p_vertex_uv4_material, GL_PRESERVE_ATI);
  983. p_mesh->p_data->k2flag &= ~(KONT2_UPLOAD);
  984. }
  985. /* Poly-listy
  986. */
  987. void poly_vertex_array_init_ati(EDIT_MESH_POLY * p_poly)
  988. {
  989. VERTEX_ARRAYS *p_varray = &p_poly->varray;
  990. p_varray->ati_handle =
  991. glNewObjectBufferATI(sizeof(p_poly->p_koord[0]) * p_poly->facenum,
  992. p_poly->p_koord, GL_DYNAMIC_ATI);
  993. }
  994. void poly_vertex_array_zrus_ati(EDIT_MESH_POLY * p_poly)
  995. {
  996. VERTEX_ARRAYS *p_varray = &p_poly->varray;
  997. if (glIsObjectBufferATI(p_varray->ati_handle)) {
  998. glFreeObjectBufferATI(p_varray->ati_handle);
  999. p_varray->ati_handle = 0;
  1000. }
  1001. }
  1002. void poly_vertex_array_upload_ati(EDIT_MESH_POLY * p_poly)
  1003. {
  1004. glUpdateObjectBufferATI(p_poly->varray.ati_handle, 0,
  1005. sizeof(p_poly->p_koord[0]) * p_poly->facenum, p_poly->p_koord,
  1006. GL_DISCARD_ATI);
  1007. }
  1008. /* Navaze aktualni renderovaci pole na poly
  1009. */
  1010. void poly_vertex_array_set_ati(EDIT_MESH_POLY * p_poly)
  1011. {
  1012. int handle = p_poly->varray.ati_handle;
  1013. int spec = p_poly->m2flag & (MAT2_SPECULAR | MAT2_ENV_SPEC)
  1014. || p_poly->kflag & KONT_DRAW_SPEC;
  1015. int norm = glstav_pn_triangles
  1016. || p_poly->
  1017. m2flag & (MAT2_CALC_MAP1 | MAT2_CALC_MAP2 | MAT2_CALC_MAP3 |
  1018. MAT2_CALC_MAP4);
  1019. int *p_int, ind;
  1020. glArrayObjectATI(GL_VERTEX_ARRAY, 3, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1021. handle, 0);
  1022. array_diffuse_on();
  1023. glArrayObjectATI(GL_COLOR_ARRAY, 4, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1024. handle, 16 * sizeof(float));
  1025. if (norm) {
  1026. array_normal_on();
  1027. glArrayObjectATI(GL_NORMAL_ARRAY, 3, GL_FLOAT,
  1028. sizeof(p_poly->p_koord[0]), handle, 3 * sizeof(float));
  1029. }
  1030. else {
  1031. array_normal_off();
  1032. }
  1033. if (spec) {
  1034. array_specular_on();
  1035. glArrayObjectATI(GL_SECONDARY_COLOR_ARRAY_EXT, 3, GL_FLOAT,
  1036. sizeof(p_poly->p_koord[0]), handle, 24 * sizeof(float));
  1037. }
  1038. else {
  1039. array_specular_off();
  1040. }
  1041. p_int = glstav_text_map_indicie;
  1042. if (glstav_text_poly_indicie > 0) {
  1043. array_text_set_num(0);
  1044. if ((ind = *p_int) != K_CHYBA) {
  1045. array_text_on();
  1046. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT,
  1047. sizeof(p_poly->p_koord[0]), handle,
  1048. (6 + ((ind) << 1)) * sizeof(float));
  1049. }
  1050. else {
  1051. array_text_off();
  1052. }
  1053. }
  1054. p_int++;
  1055. if (glstav_text_poly_indicie > 1) {
  1056. array_text_set_num(1);
  1057. if ((ind = *p_int) != K_CHYBA) {
  1058. array_text_on();
  1059. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT,
  1060. sizeof(p_poly->p_koord[0]), handle,
  1061. (6 + ((ind) << 1)) * sizeof(float));
  1062. }
  1063. else {
  1064. array_text_off();
  1065. }
  1066. }
  1067. p_int++;
  1068. if (glstav_text_poly_indicie > 2) {
  1069. array_text_set_num(2);
  1070. if ((ind = *p_int) != K_CHYBA) {
  1071. array_text_on();
  1072. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT,
  1073. sizeof(p_poly->p_koord[0]), handle,
  1074. (6 + ((ind) << 1)) * sizeof(float));
  1075. }
  1076. else {
  1077. array_text_off();
  1078. }
  1079. }
  1080. p_int++;
  1081. if (glstav_text_poly_indicie > 3) {
  1082. array_text_set_num(3);
  1083. if ((ind = *p_int) != K_CHYBA) {
  1084. array_text_on();
  1085. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT,
  1086. sizeof(p_poly->p_koord[0]), handle,
  1087. (6 + ((ind) << 1)) * sizeof(float));
  1088. }
  1089. else {
  1090. array_text_off();
  1091. }
  1092. }
  1093. array_text_set_num(glstav_text_poly_indicie);
  1094. array_text_on();
  1095. glArrayObjectATI(GL_TEXTURE_COORD_ARRAY, 2, GL_FLOAT,
  1096. sizeof(p_poly->p_koord[0]), handle, 14 * sizeof(float));
  1097. }
  1098. // vertex-araay nastavim ale nepovilim pro to co neni pozadovany?
  1099. // 1 rutina pro rendering vsech poli
  1100. void vertex_array_start_render_ati(void)
  1101. {
  1102. glEnableClientState(GL_VERTEX_ARRAY);
  1103. if (gl_ext::extlist_ati_element_array)
  1104. glEnableClientState(GL_ELEMENT_ARRAY_ATI);
  1105. array_text_set_num(0);
  1106. array_text_on();
  1107. array_text_set_num(1);
  1108. array_text_off();
  1109. array_text_set_num(2);
  1110. array_text_off();
  1111. array_text_set_num(3);
  1112. array_text_off();
  1113. }
  1114. void vertex_array_stop_render_ati(void)
  1115. {
  1116. glDisableClientState(GL_VERTEX_ARRAY);
  1117. if (gl_ext::extlist_ati_element_array)
  1118. glDisableClientState(GL_ELEMENT_ARRAY_ATI);
  1119. array_diffuse_off();
  1120. array_specular_off();
  1121. array_normal_off();
  1122. array_text_set_num(0);
  1123. array_text_off();
  1124. array_text_set_num(1);
  1125. array_text_off();
  1126. array_text_set_num(2);
  1127. array_text_off();
  1128. array_text_set_num(3);
  1129. array_text_off();
  1130. }
  1131. /* ARB vertex array - inicializuje pole
  1132. */
  1133. void mesh_vertex_array_init_arb(GAME_MESH_OLD * p_mesh)
  1134. {
  1135. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  1136. glGenBuffersARB(1, (GLuint *) & p_va->ati_handle);
  1137. glGenBuffersARB(1, (GLuint *) & p_va->arb_handle_indicie);
  1138. }
  1139. // Zrusi pole
  1140. void mesh_vertex_array_zrus_arb(GAME_MESH_OLD * p_mesh)
  1141. {
  1142. VERTEX_ARRAYS *p_varray = &p_mesh->varray;
  1143. if (glIsBufferARB(p_varray->ati_handle)) {
  1144. glDeleteBuffersARB(1, (GLuint *) & p_varray->ati_handle);
  1145. p_varray->ati_handle = 0;
  1146. }
  1147. if (glIsBufferARB(p_varray->arb_handle_indicie)) {
  1148. glDeleteBuffersARB(1, (GLuint *) & p_varray->arb_handle_indicie);
  1149. p_varray->arb_handle_indicie = 0;
  1150. }
  1151. }
  1152. // Nastavi mesh pro rendering - vertexy
  1153. void mesh_vertex_array_set_arb(GAME_MESH_OLD * p_mesh)
  1154. {
  1155. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  1156. int m2flag = p_mesh->p_data->m2flag;
  1157. int norm = glstav_pn_triangles
  1158. || m2flag & (MAT2_CALC_MAP1 | MAT2_CALC_MAP2 | MAT2_CALC_MAP3 |
  1159. MAT2_CALC_MAP4);
  1160. glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, p_va->arb_handle_indicie);
  1161. glBindBufferARB(GL_ARRAY_BUFFER_ARB, p_va->ati_handle);
  1162. glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(p_va->ati_start_pos));
  1163. if (norm) {
  1164. array_normal_on();
  1165. glNormalPointer(GL_FLOAT, 0, BUFFER_OFFSET(p_va->ati_start_norm));
  1166. }
  1167. else {
  1168. array_normal_off();
  1169. }
  1170. if (m2flag & MAT2_DIFFUSE) {
  1171. array_diffuse_on();
  1172. glColorPointer(4, GL_FLOAT, 0, BUFFER_OFFSET(p_va->ati_start_diff));
  1173. }
  1174. else {
  1175. array_diffuse_off();
  1176. }
  1177. if (m2flag & (MAT2_SPECULAR | MAT2_ENV_SPEC)
  1178. || p_mesh->p_data->kflag & KONT_DRAW_SPEC) {
  1179. array_specular_on();
  1180. glSecondaryColorPointerEXT(3, GL_FLOAT, 0,
  1181. BUFFER_OFFSET(p_va->ati_start_spec));
  1182. }
  1183. else {
  1184. array_specular_off();
  1185. }
  1186. }
  1187. // Nastavi mesh pro rendering - koordinaty
  1188. void mesh_vertex_array_set_koord_arb(GAME_MESH_OLD * p_mesh)
  1189. {
  1190. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  1191. int *p_int, ind;
  1192. p_int = glstav_text_map_indicie;
  1193. ind = *p_int++;
  1194. array_text_set_num(0);
  1195. if (ind != K_CHYBA) {
  1196. array_text_on();
  1197. glTexCoordPointer(2, GL_FLOAT, 0,
  1198. BUFFER_OFFSET(p_va->ati_start_text[ind]));
  1199. }
  1200. else {
  1201. array_text_off();
  1202. }
  1203. ind = *p_int++;
  1204. if (array_text_set_num(1)) {
  1205. if (ind != K_CHYBA) {
  1206. array_text_on();
  1207. glTexCoordPointer(2, GL_FLOAT, 0,
  1208. BUFFER_OFFSET(p_va->ati_start_text[ind]));
  1209. }
  1210. else {
  1211. array_text_off();
  1212. }
  1213. }
  1214. ind = *p_int++;
  1215. if (array_text_set_num(2)) {
  1216. if (ind != K_CHYBA) {
  1217. array_text_on();
  1218. glTexCoordPointer(2, GL_FLOAT, 0,
  1219. BUFFER_OFFSET(p_va->ati_start_text[ind]));
  1220. }
  1221. else {
  1222. array_text_off();
  1223. }
  1224. }
  1225. ind = *p_int++;
  1226. if (array_text_set_num(3)) {
  1227. if (ind != K_CHYBA) {
  1228. array_text_on();
  1229. glTexCoordPointer(2, GL_FLOAT, 0,
  1230. BUFFER_OFFSET(p_va->ati_start_text[ind]));
  1231. }
  1232. else {
  1233. array_text_off();
  1234. }
  1235. }
  1236. }
  1237. // Uploadnuje mesh do videoram po zmene
  1238. void mesh_vertex_array_upload_arb(GAME_MESH_OLD * p_mesh)
  1239. {
  1240. VERTEX_ARRAYS *p_va = &p_mesh->varray;
  1241. int vertexu = p_mesh->vertexnum,
  1242. k2flag = p_mesh->p_data->k2flag,
  1243. m2flag = p_mesh->p_data->m2flag, kflag = p_mesh->p_data->kflag;
  1244. int norm = glstav_pn_triangles
  1245. || p_mesh->p_data->
  1246. m2flag & (MAT2_CALC_MAP1 | MAT2_CALC_MAP2 | MAT2_CALC_MAP3 |
  1247. MAT2_CALC_MAP4);
  1248. if (k2flag & KONT2_UPDATE_NEW) {
  1249. glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, p_va->arb_handle_indicie);
  1250. glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
  1251. sizeof(p_mesh->p_face[0]) * p_mesh->facevel, p_mesh->p_face,
  1252. GL_STATIC_DRAW_ARB);
  1253. glBindBufferARB(GL_ARRAY_BUFFER_ARB, p_va->ati_handle);
  1254. glBufferDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_velikost,
  1255. p_mesh->p_vertex_pos, GL_DYNAMIC_DRAW_ARB);
  1256. }
  1257. glBindBufferARB(GL_ARRAY_BUFFER_ARB, p_va->ati_handle);
  1258. if (k2flag & KONT2_UPDATE_POS)
  1259. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_pos,
  1260. sizeof(p_mesh->p_vertex_pos[0]) * vertexu, p_mesh->p_vertex_pos);
  1261. if (norm && k2flag & KONT2_UPDATE_NORM)
  1262. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_norm,
  1263. sizeof(p_mesh->p_vertex_norm[0]) * vertexu, p_mesh->p_vertex_norm);
  1264. if (k2flag & KONT2_UPDATE_DIFF && m2flag & MAT2_DIFFUSE) {
  1265. if (kflag & KONT_DRAW_VODA) {
  1266. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_diff,
  1267. sizeof(p_mesh->p_vertex_diff_voda[0]) * vertexu,
  1268. p_mesh->p_vertex_diff_voda);
  1269. }
  1270. else {
  1271. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_diff,
  1272. sizeof(p_mesh->p_vertex_diff[0]) * vertexu, p_mesh->p_vertex_diff);
  1273. }
  1274. }
  1275. if (k2flag & KONT2_UPDATE_SPEC) {
  1276. if (kflag & KONT_DRAW_VODA) {
  1277. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_spec,
  1278. sizeof(p_mesh->p_vertex_spec_voda[0]) * vertexu,
  1279. p_mesh->p_vertex_spec_voda);
  1280. }
  1281. else {
  1282. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_spec,
  1283. sizeof(p_mesh->p_vertex_spec[0]) * vertexu, p_mesh->p_vertex_spec);
  1284. }
  1285. }
  1286. if (k2flag & KONT2_UPDATE_TEXT1)
  1287. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_text[0],
  1288. sizeof(p_mesh->p_vertex_uv1_material[0]) * vertexu,
  1289. p_mesh->p_vertex_uv1_material);
  1290. if (k2flag & KONT2_UPDATE_TEXT2)
  1291. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_text[1],
  1292. sizeof(p_mesh->p_vertex_uv2_material[0]) * vertexu,
  1293. p_mesh->p_vertex_uv2_material);
  1294. if (k2flag & KONT2_UPDATE_TEXT3)
  1295. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_text[2],
  1296. sizeof(p_mesh->p_vertex_uv3_material[0]) * vertexu,
  1297. p_mesh->p_vertex_uv3_material);
  1298. if (k2flag & KONT2_UPDATE_TEXT4)
  1299. glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, p_va->ati_start_text[3],
  1300. sizeof(p_mesh->p_vertex_uv4_material[0]) * vertexu,
  1301. p_mesh->p_vertex_uv4_material);
  1302. p_mesh->p_data->k2flag &= ~(KONT2_UPLOAD);
  1303. }
  1304. /* Poly-listy - inicializace
  1305. */
  1306. void poly_vertex_array_init_arb(EDIT_MESH_POLY * p_poly)
  1307. {
  1308. VERTEX_ARRAYS *p_va = &p_poly->varray;
  1309. glGenBuffersARB(1, (GLuint *) & p_va->ati_handle);
  1310. }
  1311. // Zruseni
  1312. void poly_vertex_array_zrus_arb(EDIT_MESH_POLY * p_poly)
  1313. {
  1314. VERTEX_ARRAYS *p_va = &p_poly->varray;
  1315. if (glIsBufferARB(p_va->ati_handle)) {
  1316. glDeleteBuffersARB(1, (GLuint *) & p_va->ati_handle);
  1317. p_va->ati_handle = 0;
  1318. }
  1319. }
  1320. // uploaduje poly do videoram
  1321. void poly_vertex_array_upload_arb(EDIT_MESH_POLY * p_poly)
  1322. {
  1323. VERTEX_ARRAYS *p_va = &p_poly->varray;
  1324. glBindBufferARB(GL_ARRAY_BUFFER_ARB, p_va->ati_handle);
  1325. glBufferDataARB(GL_ARRAY_BUFFER_ARB,
  1326. sizeof(p_poly->p_koord[0]) * p_poly->facenum, p_poly->p_koord,
  1327. GL_DYNAMIC_DRAW_ARB);
  1328. }
  1329. // Nastavi poly na rendering
  1330. void poly_vertex_array_set_arb(EDIT_MESH_POLY * p_poly)
  1331. {
  1332. VERTEX_ARRAYS *p_va = &p_poly->varray;
  1333. int spec = p_poly->m2flag & (MAT2_SPECULAR | MAT2_ENV_SPEC)
  1334. || p_poly->kflag & KONT_DRAW_SPEC;
  1335. int norm = glstav_pn_triangles
  1336. || p_poly->
  1337. m2flag & (MAT2_CALC_MAP1 | MAT2_CALC_MAP2 | MAT2_CALC_MAP3 |
  1338. MAT2_CALC_MAP4);
  1339. int *p_int, ind;
  1340. glBindBufferARB(GL_ARRAY_BUFFER_ARB, p_va->ati_handle);
  1341. glVertexPointer(3, GL_FLOAT, sizeof(p_poly->p_koord[0]), BUFFER_OFFSET(0));
  1342. array_diffuse_on();
  1343. glColorPointer(4, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1344. BUFFER_OFFSET(16 * sizeof(float)));
  1345. if (norm) {
  1346. array_normal_on();
  1347. glNormalPointer(GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1348. BUFFER_OFFSET(3 * sizeof(float)));
  1349. }
  1350. else {
  1351. array_normal_off();
  1352. }
  1353. if (spec) {
  1354. array_specular_on();
  1355. glSecondaryColorPointerEXT(3, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1356. BUFFER_OFFSET(24 * sizeof(float)));
  1357. }
  1358. else {
  1359. array_specular_off();
  1360. }
  1361. p_int = glstav_text_map_indicie;
  1362. if (glstav_text_poly_indicie > 0) {
  1363. array_text_set_num(0);
  1364. if ((ind = *p_int) != K_CHYBA) {
  1365. array_text_on();
  1366. glTexCoordPointer(2, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1367. BUFFER_OFFSET((6 + ((ind) << 1)) * sizeof(float)));
  1368. }
  1369. else {
  1370. array_text_off();
  1371. }
  1372. }
  1373. p_int++;
  1374. if (glstav_text_poly_indicie > 1) {
  1375. array_text_set_num(1);
  1376. if ((ind = *p_int) != K_CHYBA) {
  1377. array_text_on();
  1378. glTexCoordPointer(2, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1379. BUFFER_OFFSET((6 + ((ind) << 1)) * sizeof(float)));
  1380. }
  1381. else {
  1382. array_text_off();
  1383. }
  1384. }
  1385. p_int++;
  1386. if (glstav_text_poly_indicie > 2) {
  1387. array_text_set_num(2);
  1388. if ((ind = *p_int) != K_CHYBA) {
  1389. array_text_on();
  1390. glTexCoordPointer(2, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1391. BUFFER_OFFSET((6 + ((ind) << 1)) * sizeof(float)));
  1392. }
  1393. else {
  1394. array_text_off();
  1395. }
  1396. }
  1397. p_int++;
  1398. if (glstav_text_poly_indicie > 3) {
  1399. array_text_set_num(3);
  1400. if ((ind = *p_int) != K_CHYBA) {
  1401. array_text_on();
  1402. glTexCoordPointer(2, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1403. BUFFER_OFFSET((6 + ((ind) << 1)) * sizeof(float)));
  1404. }
  1405. else {
  1406. array_text_off();
  1407. }
  1408. }
  1409. array_text_set_num(glstav_text_poly_indicie);
  1410. array_text_on();
  1411. glTexCoordPointer(2, GL_FLOAT, sizeof(p_poly->p_koord[0]),
  1412. BUFFER_OFFSET(14 * sizeof(float)));
  1413. }
  1414. // start renderu
  1415. void vertex_array_start_render_arb(void)
  1416. {
  1417. glEnableClientState(GL_VERTEX_ARRAY);
  1418. array_text_set_num(0);
  1419. array_text_on();
  1420. array_text_set_num(1);
  1421. array_text_off();
  1422. array_text_set_num(2);
  1423. array_text_off();
  1424. array_text_set_num(3);
  1425. array_text_off();
  1426. }
  1427. // stop renderu
  1428. void vertex_array_stop_render_arb(void)
  1429. {
  1430. glDisableClientState(GL_VERTEX_ARRAY);
  1431. array_diffuse_off();
  1432. array_specular_off();
  1433. array_normal_off();
  1434. array_text_set_num(0);
  1435. array_text_off();
  1436. array_text_set_num(1);
  1437. array_text_off();
  1438. array_text_set_num(2);
  1439. array_text_off();
  1440. array_text_set_num(3);
  1441. array_text_off();
  1442. }
  1443. /* Univerzalni pointer-based
  1444. */
  1445. void (*mesh_vertex_array_init) (GAME_MESH_OLD * p_mesh);
  1446. void (*mesh_vertex_array_zrus) (GAME_MESH_OLD * p_mesh);
  1447. void (*mesh_vertex_array_upload) (GAME_MESH_OLD * p_mesh);
  1448. void (*mesh_vertex_array_set) (GAME_MESH_OLD * p_mesh);
  1449. void (*mesh_vertex_array_set_koord) (GAME_MESH_OLD * p_mesh);
  1450. void (*vertex_array_start_render) (void);
  1451. void (*vertex_array_stop_render) (void);
  1452. void (*poly_vertex_array_init) (EDIT_MESH_POLY * p_poly);
  1453. void (*poly_vertex_array_zrus) (EDIT_MESH_POLY * p_poly);
  1454. void (*poly_vertex_array_upload) (EDIT_MESH_POLY * p_poly);
  1455. void (*poly_vertex_array_set) (EDIT_MESH_POLY * p_poly);
  1456. void vertex_array_start_render_nic(void)
  1457. {
  1458. };
  1459. void vertex_array_stop_render_nic(void)
  1460. {
  1461. };
  1462. /* Inicializuje vretexove pole podle podporovanych extenzi
  1463. */
  1464. void vertex_array_ini(void)
  1465. {
  1466. if (gl_ext::extlist_arb_vertex_buffer) {
  1467. gl_ext::extlist_vertex_array = TRUE;
  1468. gl_ext::extlist_indicie_array = TRUE;
  1469. poly_vertex_array_init = poly_vertex_array_init_arb;
  1470. poly_vertex_array_zrus = poly_vertex_array_zrus_arb;
  1471. poly_vertex_array_upload = poly_vertex_array_upload_arb;
  1472. poly_vertex_array_set = poly_vertex_array_set_arb;
  1473. mesh_vertex_array_init = mesh_vertex_array_init_arb;
  1474. mesh_vertex_array_zrus = mesh_vertex_array_zrus_arb;
  1475. mesh_vertex_array_upload = mesh_vertex_array_upload_arb;
  1476. mesh_vertex_array_set = mesh_vertex_array_set_arb;
  1477. mesh_vertex_array_set_koord = mesh_vertex_array_set_koord_arb;
  1478. vertex_array_start_render = vertex_array_start_render_arb;
  1479. vertex_array_stop_render = vertex_array_stop_render_arb;
  1480. }
  1481. else if (gl_ext::extlist_ati_vertex_array_object) {
  1482. gl_ext::extlist_vertex_array = gl_ext::extlist_ati_vertex_array_object;
  1483. gl_ext::extlist_indicie_array = gl_ext::extlist_ati_element_array;
  1484. poly_vertex_array_init = poly_vertex_array_init_ati;
  1485. poly_vertex_array_zrus = poly_vertex_array_zrus_ati;
  1486. poly_vertex_array_upload = poly_vertex_array_upload_ati;
  1487. poly_vertex_array_set = poly_vertex_array_set_ati;
  1488. mesh_vertex_array_init = mesh_vertex_array_init_ati;
  1489. mesh_vertex_array_zrus = mesh_vertex_array_zrus_ati;
  1490. mesh_vertex_array_upload = mesh_vertex_array_upload_ati;
  1491. mesh_vertex_array_set = mesh_vertex_array_set_ati;
  1492. mesh_vertex_array_set_koord = mesh_vertex_array_set_koord_ati;
  1493. vertex_array_start_render = vertex_array_start_render_ati;
  1494. vertex_array_stop_render = vertex_array_stop_render_ati;
  1495. }
  1496. else {
  1497. vertex_array_start_render = vertex_array_start_render_nic;
  1498. vertex_array_stop_render = vertex_array_stop_render_nic;
  1499. assert(0);
  1500. }
  1501. }