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_Gen.h
0004 ===============
0005 
0006 
0007 **/
0008 
0009 
0010 struct SGLFW_Program ;
0011 struct SGen ;
0012 
0013 struct SGLFW_Gen
0014 {
0015     static SGLFW_Gen* Create(const SGen* _genstep, const float* _timeparam_ptr  );
0016 
0017     const SGen*         genstep ;
0018     const float*        timeparam_ptr ;
0019 
0020     SGLFW_Buffer*       buf ;
0021     SGLFW_VAO*          vao ;
0022     GLint               param_location;
0023 
0024     SGLFW_Gen(const SGen* _genstep, const float* _timeparam_ptr  ) ;
0025     void init();
0026 
0027     void render(const SGLFW_Program* prog);
0028 };
0029 
0030 
0031 inline SGLFW_Gen* SGLFW_Gen::Create(const SGen* _genstep, const float* _timeparam_ptr )
0032 {
0033     return _genstep ? new SGLFW_Gen(_genstep, _timeparam_ptr) : nullptr ;
0034 }
0035 
0036 
0037 inline SGLFW_Gen::SGLFW_Gen(const SGen* _genstep, const float* _timeparam_ptr )
0038     :
0039     genstep(_genstep),
0040     timeparam_ptr(_timeparam_ptr),
0041     buf(nullptr),
0042     vao(nullptr),
0043     param_location(0)
0044 {
0045     init();
0046 }
0047 
0048 /**
0049 SGLFW_Gen::init
0050 ----------------
0051 
0052 
0053 **/
0054 
0055 
0056 inline void SGLFW_Gen::init()
0057 {
0058     vao = new SGLFW_VAO("SGLFW_Gen.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_Gen.buf", genstep->genstep->arr_bytes(), genstep->genstep->cvalues<float>(), GL_ARRAY_BUFFER,  GL_STATIC_DRAW );
0062     buf->bind();
0063     buf->upload();
0064 }
0065 
0066 
0067 /**
0068 SGLFW_Gen::render
0069 ---------------------
0070 
0071 Called from renderloop.
0072 
0073 **/
0074 
0075 inline void SGLFW_Gen::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", SGen::RPOS_SPEC );
0083     prog->enableVertexAttribArray("rdel", SGen::RDEL_SPEC );
0084 
0085 
0086     if(param_location > -1 ) prog->Uniform4fv(param_location, timeparam_ptr, false );
0087     prog->updateMVP();  // ?
0088 
0089     GLenum mode = prog->geometry_shader_text ? GL_LINE_STRIP : GL_POINTS ;
0090     glDrawArrays(mode, genstep->genstep_first,  genstep->genstep_count);
0091 }
0092 
0093