Forums > Jitter

opengl texture setting in jit.gl.sketch

July 24, 2009 | 7:13 pm

Hi

I know I’m missing a gl command about texture wrapping or my texture is the wrong shape or something like that but I can’t get my texture to only display once and the correct way (not flipped over on the x-axis) – any ideas?

Garrett

max v2;
#N vpatcher 158 168 861 881;
#P origin 0 -27;
#P window setfont "Sans Serif" 9.;
#P window linecount 5;
#P message 248 551 350 196617 reset , glmatrixmode modelview , glpushmatrix , glcolor 1. 1. 1. 1. , glenable texture_2d , glbindtexture line1tex , glenable blend , glblendfunc 7 7 , glbegin quads , gltexcoord -1. 0.5 , glvertex -1. 0.5 , gltexcoord 1. 0.5 , glvertex 1. 0.5 , gltexcoord 1. -0.5 , glvertex 1. -0.5 , gltexcoord -1. -0.5 , glvertex -1. -0.5 , glend , gldisable texture_2d , gldisable blend , glpopmatrix ,;
#P window linecount 1;
#P message 197 601 32 196617 reset;
#P flonum 144 582 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 144 601 51 196617 radius $1;
#P newex 144 620 103 196617 jit.gl.handle example;
#P newex 76 228 74 196617 r line1texture;
#P newex 299 507 74 196617 s line1texture;
#P message 82 66 68 196617 fullscreen $1;
#P toggle 65 66 15 0;
#P newex 107 41 35 196617 sel 27;
#P newex 65 41 40 196617 key;
#P newex 248 620 148 196617 jit.gl.sketch example @layer 1;
#P newex 248 287 48 196617 loadbang;
#P message 263 334 306 196617 write "hello world how are you today i am fine thanks for asking";
#P newex 248 308 40 196617 t b b b;
#P message 298 380 67 196617 moveto 0 20;
#P newex 264 353 62 196617 t b l b clear;
#P newex 299 465 143 196617 jit.matrix @planemap 1 0 0 0;
#P newex 299 486 122 196617 prepend texture line1tex;
#P newex 299 443 129 196617 jit.matrix 4 char 256 256;
#P message 378 380 269 196617 reset , brgb 0 0 0 , frgb 255 255 255 , font "Gill Sans" 20;
#P newex 299 421 111 196617 jit.lcd 4 char 256 256;
#P newex 65 190 50 196617 t b erase;
#P hidden newex 65 121 48 196617 loadbang;
#P newex 65 167 57 196617 qmetro 40;
#P toggle 65 145 15 0;
#P newex 65 87 164 196617 jit.window example 5 44 805 644;
#B color 5;
#P newex 65 251 276 196617 jit.gl.render example @erase_color 0. 0. 0. 1. @antialias 1;
#B color 5;
#P window linecount 2;
#P comment 405 354 216 196617 make sure font size and moveto are the same otherwise you won’t see the text;
#P fasten 19 0 20 0 112 63 70 63;
#P connect 21 0 2 0;
#P hidden connect 5 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 6 0;
#P connect 23 0 1 0;
#P fasten 6 1 1 0 110 223 70 223;
#P connect 6 0 1 0;
#P fasten 20 0 21 0 81 81 81 66;
#P fasten 18 0 19 0 106 58 106 43;
#P connect 26 0 25 0;
#P connect 27 0 24 0;
#P connect 25 0 24 0;
#P connect 16 0 14 0;
#P connect 14 0 28 0;
#P connect 24 0 17 0;
#P connect 28 0 17 0;
#P connect 14 1 15 0;
#P connect 15 0 12 0;
#P connect 12 2 13 0;
#P connect 13 0 7 0;
#P connect 8 0 7 0;
#P connect 12 3 7 0;
#P connect 12 1 7 0;
#P connect 12 0 7 0;
#P connect 7 0 9 0;
#P connect 9 0 11 0;
#P connect 11 0 10 0;
#P connect 10 0 22 0;
#P connect 14 2 8 0;
#P pop;


July 24, 2009 | 7:40 pm

reset, glmatrixmode modelview, glpushmatrix, glcolor 1. 1. 1. 1., glenable texture_2d, glbindtexture line1tex, glenable blend, glblendfunc 7 7, glbegin quads, gltexcoord -1. -0.5, glvertex -1. 0.5, gltexcoord 1. -0.5, glvertex 1. 0.5, gltexcoord 1. 0.5, glvertex 1. -0.5, gltexcoord -1. 0.5, glvertex -1. -0.5, glend, gldisable texture_2d, gldisable blend, glpopmatrix,

July 24, 2009 | 8:01 pm

so texture mapping is clockwise from top left and quad drawing is anti-clockwise from bottom left. mmmmm bit confusing. thanks.

on topic whats a good opengl book to read apart from the red and blue books, someone here recommended this:

http://www.amazon.co.uk/opengl-R-Distilled-Paul-Martz/dp/0321336798/ref=pd_bbs_sr_9?ie=UTF8&s=books&qid=1231880182&sr=8-9

what have you used?

Garrett


July 24, 2009 | 8:15 pm

reset, glmatrixmode modelview, glpushmatrix, glcolor 1. 1. 1. 1., glbindtexture line1tex, glenable blend, glblendfunc 7 7, glbegin quads, gltexcoord -1. -0.5, glvertex -1. 0.5, gltexcoord 1. -0.5, glvertex 1. 0.5, gltexcoord 1. 0.5, glvertex 1. -0.5, gltexcoord -1. 0.5, glvertex -1. -0.5, glend, gldisable blend, glpopmatrix,

You don’t actually need the glenable/disable of texture_2d. Jitter takes care of that for you with the glbindtexture command

wes


July 24, 2009 | 8:19 pm

oh and what about the repeating? I’m missing something about how the texture maps, I only want the line of text to show once.

Garrett


July 24, 2009 | 8:55 pm

texture coordinates go from 0,0 to 1,1 (top left to bottom right, i think).
extending beyond that range causes the tiling.

reset, glmatrixmode modelview, glpushmatrix, glcolor 1. 1. 1. 1., glbindtexture line1tex, glenable blend, glblendfunc 7 7, glbegin quads, gltexcoord 0. 0., glvertex -1. 0.5, gltexcoord 1. 0., glvertex 1. 0.5, gltexcoord 1. 1., glvertex 1. -0.5, gltexcoord 0. 1., glvertex -1. -0.5, glend, gldisable blend, glpopmatrix

July 24, 2009 | 11:09 pm

beginning to make more sense now, many thanks.

Garrett


July 25, 2009 | 10:38 pm

Hi

Almost there I think. I’m working from an example that was here on the forum (can’t find it now so I’ve attached it in a zip) but I can’t get my text to render at exactly its correct size (i.e. as smooth as in the attached file). I know I’m just wrong on a few pixels somewhere but can’t seem to figure out whether its in the matrix creation or in the gl drawing part. Thanks in advance.

Garrett

max v2;
#N vpatcher 266 44 1068 854;
#P origin 40 -7;
#P button 223 274 53 0;
#P window setfont "Sans Serif" 9.;
#P newex 259 600 30 196617 t b s;
#P user jit.pwindow 153 521 601 23 0 1 0 0 1 0;
#P window linecount 6;
#P message 205 643 343 196617 reset , glmatrixmode projection , glloadidentity , glortho 0. 800 600 0. -5. 5. , glmatrixmode modelview , glloadidentity , glpushmatrix , gltranslate 10 300 0 , glcolor 1. 1. 1. 1. , glbindtexture line1tex , glenable blend , glblendfunc 6 7 , glscale 600 15 , glbegin quads , gltexcoord 0. 1. , glvertex 0. 1. , gltexcoord 1. 1. , glvertex 1. 1. , gltexcoord 1. 0. , glvertex 1. -1. , gltexcoord 0. 0. , glvertex 0. -1. , glend , gldisable blend , glpopmatrix;
#P window linecount 1;
#P message 154 712 32 196617 reset;
#P flonum 101 693 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 101 712 51 196617 radius $1;
#P newex 101 731 103 196617 jit.gl.handle example;
#P newex 36 208 74 196617 r line1texture;
#P newex 279 623 74 196617 s line1texture;
#P message 42 46 68 196617 fullscreen $1;
#P toggle 25 46 15 0;
#P newex 67 21 35 196617 sel 27;
#P newex 25 21 40 196617 key;
#P newex 205 731 148 196617 jit.gl.sketch example @layer 1;
#P window linecount 2;
#P message 223 354 393 196617 write "hello world how are you today i am fine thanks for asking hello world how are you today i am fine thanks for asking hello world how are you today i am fine than";
#P window linecount 1;
#P newex 223 331 30 196617 t b b;
#P message 258 417 67 196617 moveto 0 18;
#P newex 224 390 62 196617 t b l b clear;
#P newex 259 556 143 196617 jit.matrix @planemap 1 0 0 0;
#P newex 259 577 122 196617 prepend texture line1tex;
#P window linecount 2;
#P newex 259 484 319 196617 jit.matrix 4 char 600 21 @usesrcdim 1 @usedstdim 1 @srcdimstart 0 0 @srcdimend 599 20 @dstdimstart 0 0 @dstdimend 599 20;
#P window linecount 1;
#P message 338 417 226 196617 reset , brgb 0 0 0 , frgb 255 255 255 , font 4 15;
#P newex 259 458 105 196617 jit.lcd 4 char 600 20;
#P newex 25 170 50 196617 t b erase;
#P hidden newex 25 101 48 196617 loadbang;
#P newex 25 147 57 196617 qmetro 40;
#P toggle 25 125 15 0;
#P newex 25 67 164 196617 jit.window example 5 44 805 644;
#B color 5;
#P newex 25 231 218 196617 jit.gl.render example @erase_color 0. 0. 0. 1.;
#B color 5;
#P comment 290 297 100 196617 < click me;
#P fasten 18 0 19 0 72 43 30 43;
#P connect 20 0 2 0;
#P hidden connect 5 0 3 0;
#P connect 3 0 4 0;
#P connect 4 0 6 0;
#P connect 22 0 1 0;
#P fasten 6 1 1 0 70 203 30 203;
#P connect 6 0 1 0;
#P fasten 19 0 20 0 41 61 41 46;
#P fasten 17 0 18 0 66 38 66 23;
#P connect 25 0 24 0;
#P connect 24 0 23 0;
#P connect 26 0 23 0;
#P connect 9 0 28 0;
#P connect 29 0 27 0;
#P connect 23 0 16 0;
#P connect 27 0 16 0;
#P connect 30 0 14 0;
#P connect 14 0 15 0;
#P connect 15 0 12 0;
#P connect 12 2 13 0;
#P connect 13 0 7 0;
#P connect 8 0 7 0;
#P connect 12 3 7 0;
#P connect 12 1 7 0;
#P connect 12 0 7 0;
#P connect 7 0 9 0;
#P connect 28 0 11 0;
#P connect 11 0 10 0;
#P connect 10 0 29 0;
#P connect 29 1 21 0;
#P connect 14 1 8 0;
#P pop;


July 27, 2009 | 11:23 am

Bump, anyone??

Garrett


July 28, 2009 | 6:26 pm

i’m not sure what you are asking.


Viewing 10 posts - 1 through 10 (of 10 total)