Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:38

0001 #pragma once
0002 /**
0003 SGLFW_Record.h
0004 ===============
0005 
0006 
0007 **/
0008 
0009 
0010 struct SGLFW_Program ;
0011 struct SRecord ;
0012 
0013 struct SGLFW_Record
0014 {
0015     static SGLFW_Record* Create(const SRecord* _record, const float* _timeparam_ptr  );
0016 
0017     const SRecord*      record ;
0018     const float*        timeparam_ptr ;
0019 
0020     SGLFW_Buffer*       buf ;
0021     SGLFW_VAO*          vao ;
0022     GLint               param_location;
0023 
0024     SGLFW_Record(const SRecord* _record, const float* _timeparam_ptr  ) ;
0025     void init();
0026 
0027     void render(const SGLFW_Program* prog);
0028 };
0029 
0030 
0031 inline SGLFW_Record* SGLFW_Record::Create(const SRecord* _record, const float* _timeparam_ptr )
0032 {
0033     return _record ? new SGLFW_Record(_record, _timeparam_ptr) : nullptr ;
0034 }
0035 
0036 
0037 inline SGLFW_Record::SGLFW_Record(const SRecord* _record, const float* _timeparam_ptr )
0038     :
0039     record(_record),
0040     timeparam_ptr(_timeparam_ptr),
0041     buf(nullptr),
0042     vao(nullptr),
0043     param_location(0)
0044 {
0045     init();
0046 }
0047 
0048 /**
0049 SGLFW_Record::init
0050 ----------------
0051 
0052 
0053 **/
0054 
0055 
0056 inline void SGLFW_Record::init()
0057 {
0058     vao = new SGLFW_VAO("SGLFW_Record.vao") ;  // vao: establishes context for OpenGL attrib state and element array (not GL_ARRAY_BUFFER)
0059     vao->bind();
0060 
0061     buf = new SGLFW_Buffer("SGLFW_Record.buf", record->record->arr_bytes(), record->record->cvalues<float>(), GL_ARRAY_BUFFER,  GL_STATIC_DRAW );
0062     buf->bind();
0063     buf->upload();
0064 }
0065 
0066 
0067 /**
0068 SGLFW_Record::render
0069 ---------------------
0070 
0071 Called from renderloop.
0072 
0073 **/
0074 
0075 inline void SGLFW_Record::render(const SGLFW_Program* prog)
0076 {
0077     param_location = prog->getUniformLocation("Param");
0078     prog->use();
0079     vao->bind();
0080 
0081     buf->bind();
0082     prog->enableVertexAttribArray("rpos", SRecord::RPOS_SPEC );
0083 
0084     if(param_location > -1 ) prog->Uniform4fv(param_location, timeparam_ptr, false );
0085     prog->updateMVP();  // ?
0086 
0087     GLenum mode = prog->geometry_shader_text ? GL_LINE_STRIP : GL_POINTS ;
0088     glDrawArrays(mode, record->record_first,  record->record_count);
0089 }
0090 
0091