Changeset 2091 for trunk/tools


Ignore:
Timestamp:
Nov 19, 2012, 1:45:44 AM (8 years ago)
Author:
sam
Message:

neercs: use gl_VertexID instead of sending a whole new vertex array.

Location:
trunk/tools/neercs/video
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/video/text-render.cpp

    r2090 r2091  
    4545
    4646    m_shader = Shader::Create(lolfx_text);
    47     m_coord = m_shader->GetAttribLocation("in_Position",
    48                                           VertexUsage::Position, 0);
    4947    m_color = m_shader->GetAttribLocation("in_Attr",
    5048                                          VertexUsage::Color, 0);
     
    5351    m_texture = m_shader->GetUniformLocation("u_Texture");
    5452    m_transform = m_shader->GetUniformLocation("u_Transform");
    55     m_pointsize = m_shader->GetUniformLocation("u_PointSize");
     53    m_datasize = m_shader->GetUniformLocation("u_DataSize");
    5654    m_vdecl
    57       = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position),
    58                               VertexStream<uint32_t>(VertexUsage::Color),
     55      = new VertexDeclaration(VertexStream<uint32_t>(VertexUsage::Color),
    5956                              VertexStream<uint32_t>(VertexUsage::Color));
    6057
     
    6461void TextRender::CreateBuffers()
    6562{
    66     m_vbo1 = new VertexBuffer(m_cells * sizeof(vec2));
    67     vec2 *vertices = (vec2 *)m_vbo1->Lock(0, 0);
    68     for (int j = 0; j < m_canvas_size.y; j++)
    69     for (int i = 0; i < m_canvas_size.x; i++)
    70         vertices[j * m_canvas_size.x + i] = vec2(i, j);
    71     m_vbo1->Unlock();
    72 
    7363    m_vbo2 = new VertexBuffer(m_cells * sizeof(int32_t));
    7464    m_vbo3 = new VertexBuffer(m_cells * sizeof(int32_t));
     
    8474    if (current_size != m_canvas_size)
    8575    {
    86         delete m_vbo1;
    8776        delete m_vbo2;
    8877        delete m_vbo3;
     
    141130    m_shader->SetUniform(m_texture, 0);
    142131    m_shader->SetUniform(m_transform, xform);
    143     m_shader->SetUniform(m_pointsize, (float)max(m_font_size.x, m_font_size.y));
    144     m_vdecl->SetStream(m_vbo1, m_coord);
     132    m_shader->SetUniform(m_datasize, vec2(m_canvas_size.x,
     133                                          max(m_font_size.x, m_font_size.y)));
    145134    m_vdecl->SetStream(m_vbo2, m_color);
    146135    m_vdecl->SetStream(m_vbo3, m_char);
  • trunk/tools/neercs/video/text-render.h

    r2090 r2091  
    2323
    2424    Shader *m_shader;
    25     ShaderAttrib m_coord, m_color, m_char;
    26     ShaderUniform m_texture, m_transform, m_pointsize;
     25    ShaderAttrib m_color, m_char;
     26    ShaderUniform m_texture, m_transform, m_datasize;
    2727    VertexDeclaration *m_vdecl;
    28     VertexBuffer *m_vbo1, *m_vbo2, *m_vbo3;
     28    VertexBuffer *m_vbo2, *m_vbo3;
    2929
    3030    FrameBuffer *m_fbo;
  • trunk/tools/neercs/video/text.lolfx

    r2090 r2091  
    55#define HAVE_UINT 1
    66
    7 attribute vec2 in_Position;
    87#if HAVE_UINT
    98attribute uint in_Char, in_Attr;
     
    1615varying vec2 pass_UV;
    1716
    18 uniform float u_PointSize;
     17uniform vec2 u_DataSize;
    1918uniform mat4 u_Transform;
    2019
     
    5857
    5958    // This only works with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
    60     gl_PointSize = u_PointSize;
     59    gl_PointSize = u_DataSize[1];
    6160
    62     gl_Position = u_Transform * vec4(in_Position, 0.0, 1.0);
     61    vec2 coord = vec2(gl_VertexID % int(u_DataSize[0]),
     62                      gl_VertexID / int(u_DataSize[0]));
     63    gl_Position = u_Transform * vec4(coord, 0.0, 1.0);
    6364}
    6465
Note: See TracChangeset for help on using the changeset viewer.