OpenGL Scene to Screen Transformation -


i want use >opengl3 render regular 2d hexagon screen, wider should be.

here hexagon array (local coordinates):

float a[6][4] = {{ -1.0,0.0f, 0.0f, 1.0f }, { -sin30, cos30, 0.0f, 1.0f }, {-sin30, -cos30, 0.0f, 1.0f }, {sin30, cos30, 0.0f, 1.0f },{sin30, -cos30, 0.0f, 1.0f },{1.0, 0.0, 0.0f, 1.0f }}; 

now transform hexagon world coordinates:

for(int i=0;i<6;i++)     {         a[i][0] = a[i][0]*600+(float)width/2.0;         a[i][1] = a[i][1]*600+(float)height/2.0;         a[i][2] = a[i][2]*600;         //a[i][3] = a[i][3]*600;     } 

my vertex-shader should convert screen:

float arr[4][4] = { {2.0/(float)width, 0.0, 0.0, -1.0},                         {0.0, 2.0/(float)height, 0.0, -1.0},                         {0.0, 0.0, 0.0, 0.0},                         {0.0, 0.0, 0.0, 1.0}};  char* code2 =     {         "#version 120\n"\         "\n"\         "layout(location=0) in vec4 in_position;\n"\         "layout(location=1) in vec4 in_color;\n"\         "out vec4 ex_color;\n"\         "uniform mat4 transform;\n"\         "\n"\         "void main(void)\n"\         "{\n"\         "   gl_position = transform*in_position;\n"\         "   ex_color = in_color;\n"\         "}\n"     }; 

i work on windows pc , call glviewport(0,0,width,height); before , draw 2d objects. shader correct matrix (coloumnmajor). ideas correct deformation?


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -