Changeset 1476
- Timestamp:
- Jun 14, 2012, 8:23:06 PM (9 years ago)
- Location:
- trunk/neercs/video
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/neercs/video/render.cpp
r1474 r1476 40 40 41 41 #define DEBUG 1 // debug flag //#if defined(_DEBUG) 42 #define SHADER 1// shader flag42 #define SHADER 0 // shader flag 43 43 #define FUCK 0 // test flag 44 44 #define PI 3.1415926535f // pi … … 198 198 m_vdecl 199 199 = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position), 200 VertexStream< int32_t>(VertexUsage::Color),201 VertexStream< int32_t>(VertexUsage::Color));200 VertexStream<uint32_t>(VertexUsage::Color), 201 VertexStream<uint32_t>(VertexUsage::Color)); 202 202 203 203 m_vbo1 = new VertexBuffer(m_vertices.Bytes()); … … 231 231 232 232 void *chars = m_vbo3->Lock(0, 0); 233 for (int j = 0; j < m_height; j++)234 for (int i = 0; i < m_width; i++)235 {236 uint32_t ch = caca_get_char(m_caca, i, j);237 //ch = ch << 1;//(ch & 0xf) | ((ch & 0xf0) << 4);238 caca_put_char(m_caca, i, j, ch);239 // printf("%i %i: %08x -> ", i, j, ch);240 }241 233 memcpy(chars, caca_get_canvas_chars(m_caca), 242 234 m_width * m_height * sizeof(uint32_t)); 243 235 m_vbo3->Unlock(); 244 236 237 glEnable(GL_POINT_SPRITE); 238 //glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 245 239 glDisable(GL_POINT_SMOOTH); 246 240 glPointSize(16.f); … … 382 376 glEnable(GL_CULL_FACE); // disable cull face 383 377 glCullFace(GL_BACK); // don't draw front face 384 glEnableClientState(GL_VERTEX_ARRAY);385 glEnableClientState(GL_TEXTURE_COORD_ARRAY);386 378 // load texture 387 379 tex_map = new TileSet("neercs/video/resource/map.png", ivec2(256, 256), ivec2(1)); … … 542 534 } 543 535 536 glEnableClientState(GL_VERTEX_ARRAY); 537 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 544 538 Draw2D(); 545 539 Draw3D(); 540 glDisableClientState(GL_VERTEX_ARRAY); 541 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 546 542 #if FUCK 547 543 text_render->Blit(); -
trunk/neercs/video/text.lolfx
r1472 r1476 1 1 -- GLSL.Vert -- 2 2 3 #version 1 303 #version 150 4 4 5 5 #if 0 … … 11 11 #endif 12 12 attribute vec2 in_Position; 13 attribute uint in_Char; 14 //attribute vec4 in_Char; 15 attribute vec4 in_Color; 13 attribute uint in_Char, in_Attr; 16 14 17 15 varying vec4 pass_Foreground; … … 21 19 void main() 22 20 { 23 float u = float((in_Char >> 17u) & 0xfu) / 32.0 + 0.0; 24 // bits 25 // 1: 0 // 2: 0 // 4: 0 // 8: 0 26 // 16: 0 32: 0 64: 0 128: 0 27 // ... 28 // 17: bit 0 29 // 18: bit 1 30 // 19: bit 2 31 // 20: bit 3 32 //float u = float(in_Char & 2097152u) / 2097152.0 / 32.0; 33 float v = float((in_Char >> 21u) & 0xfu) / 32.0 + 0.5; 34 //float v = float(2) / 32.0 + 0.5; 35 //float ch = in_Char * 255.0; 36 // float u = (in_Char - mod(in_Char, 1.0 / 16.0)) * 0.5; 37 // float v = 0.5 - mod(in_Char, 1.0 / 16.0) * 8.0;// - 13.5 / 32.0; 21 float u = float(in_Char & 0xfu) / 32.0 + 0.0; 22 float v = float((in_Char >> 4u) & 0xfu) / 32.0 + 0.5; 38 23 pass_UV = vec2(u, v); 39 //pass_UV = in_Char.xy / 256;40 24 41 float r = in_Color.r;42 float g = in_Color.g;43 float b = in_Color.b;44 float a = in_Color.a;25 float A = float(in_Attr >> 29u) / 7.0; 26 float B = float((in_Attr >> 25u) & 0xfu) / 15.0; 27 float C = float((in_Attr >> 21u) & 0xfu) / 15.0; 28 float D = float((in_Attr >> 18u) & 0x7u) / 7.0; 45 29 46 float A = r - mod(r, 1.0 / 8.0); 47 float B = mod(r, 1.0 / 8.0) * 8.0; 48 B = B - mod(B, 1.0 / 16.0); 49 float C = mod(r, 1.0 / 128.0) 50 + (g - mod(g, 1.0 / 8.0)) / 8.0; 51 float D = mod(g, 1.0 / 8.0) * 8.0; 52 D = D - mod(D, 1.0 / 8.0); 30 float E = float((in_Attr >> 15u) & 0x7u) / 7.0; 31 float F = float((in_Attr >> 11u) & 0xfu) / 15.0; 32 float G = float((in_Attr >> 7u) & 0xfu) / 15.0; 33 float H = float((in_Attr >> 4u) & 0x7u) / 7.0; 53 34 54 35 pass_Background = vec4(B, C, D, 1.0); 55 pass_Foreground = vec4(1.0, 0.0, 1.0, 1.0); 56 //pass_Background = vec4(0.0, 0.0, 1.0, 1.0); 57 //pass_Foreground = vec4(0.0, 1.0, 0.0, 1.0); 36 //pass_Foreground = vec4(F, G, H, 1.0); 37 pass_Foreground = vec4(1.0, 1.0, H, 1.0); 58 38 39 // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 40 //gl_PointSize = 40; 59 41 gl_Position = vec4(in_Position, 0.0, 1.0); 60 42 } … … 62 44 -- GLSL.Frag -- 63 45 64 #version 1 3046 #version 150 65 47 66 48 varying vec4 pass_Foreground; … … 75 57 float t = texture2D(in_Texture, c).x; 76 58 gl_FragColor = mix(pass_Background, pass_Foreground, t); 77 gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);78 59 } 79 60
Note: See TracChangeset
for help on using the changeset viewer.