PDA

View Full Version : obj to opengl c++



designer_2011
12-27-2011, 02:06 AM
hi,
i have to convert .obj(cylinder model) to c++/opengl using jeffprod.com tools, but i not able to edit that code, below i have attached that code, any example program:


static GLfloat v_triangles[] = {2.75287f,0.295577f,-2.000077f,3.236193f,0.295577f,-1.051503f,0.0f,0.295577f,0.0f,
2.000077f,0.295577f,-2.75287f,2.75287f,0.295577f,-2.000077f,0.0f,0.295577f,0.0f,
1.051503f,0.295577f,-3.236192f,2.000077f,0.295577f,-2.75287f,0.0f,0.295577f,0.0f,
0.0f,0.295577f,-3.402734f,1.051503f,0.295577f,-3.236192f,0.0f,0.295577f,0.0f,
-1.051503f,0.295577f,-3.236192f,0.0f,0.295577f,-3.402734f,0.0f,0.295577f,0.0f,
-2.000077f,0.295577f,-2.752869f,-1.051503f,0.295577f,-3.236192f,0.0f,0.295577f,0.0f,
-2.752869f,0.295577f,-2.000076f,-2.000077f,0.295577f,-2.752869f,0.0f,0.295577f,0.0f,
-3.236192f,0.295577f,-1.051502f,-2.752869f,0.295577f,-2.000076f,0.0f,0.295577f,0.0f,
-3.402733f,0.295577f,0.0f,-3.236192f,0.295577f,-1.051502f,0.0f,0.295577f,0.0f,
-3.236192f,0.295577f,1.051502f,-3.402733f,0.295577f,0.0f,0.0f,0.295577f,0.0f,
-2.752869f,0.295577f,2.000076f,-3.236192f,0.295577f,1.051502f,0.0f,0.295577f,0.0f,
-2.000076f,0.295577f,2.752869f,-2.752869f,0.295577f,2.000076f,0.0f,0.295577f,0.0f,
-1.051502f,0.295577f,3.236191f,-2.000076f,0.295577f,2.752869f,0.0f,0.295577f,0.0f,
0.0f,0.295577f,3.402733f,-1.051502f,0.295577f,3.236191f,0.0f,0.295577f,0.0f,
1.051502f,0.295577f,3.236191f,0.0f,0.295577f,3.402 733f,0.0f,0.295577f,0.0f,
2.000076f,0.295577f,2.752868f,1.051502f,0.295577f, 3.236191f,0.0f,0.295577f,0.0f,
2.752868f,0.295577f,2.000076f,2.000076f,0.295577f, 2.752868f,0.0f,0.295577f,0.0f,
3.236191f,0.295577f,1.051502f,2.752868f,0.295577f, 2.000076f,0.0f,0.295577f,0.0f,
3.402732f,0.295577f,0.0f,3.236191f,0.295577f,1.051 502f,0.0f,0.295577f,0.0f,
3.236193f,0.295577f,-1.051503f,3.402732f,0.295577f,0.0f,0.0f,0.295577f, 0.0f,
3.236193f,7.101041f,-1.051503f,2.75287f,7.101041f,-2.000077f,0.0f,7.101041f,0.0f,
2.75287f,7.101041f,-2.000077f,2.000077f,7.101041f,-2.75287f,0.0f,7.101041f,0.0f,
2.000077f,7.101041f,-2.75287f,1.051503f,7.101041f,-3.236192f,0.0f,7.101041f,0.0f,
1.051503f,7.101041f,-3.236192f,0.0f,7.101041f,-3.402734f,0.0f,7.101041f,0.0f,
0.0f,7.101041f,-3.402734f,-1.051503f,7.101041f,-3.236192f,0.0f,7.101041f,0.0f,
-1.051503f,7.101041f,-3.236192f,-2.000077f,7.101041f,-2.752869f,0.0f,7.101041f,0.0f,
-2.000077f,7.101041f,-2.752869f,-2.752869f,7.101041f,-2.000076f,0.0f,7.101041f,0.0f,
-2.752869f,7.101041f,-2.000076f,-3.236192f,7.101041f,-1.051502f,0.0f,7.101041f,0.0f,
-3.236192f,7.101041f,-1.051502f,-3.402733f,7.101041f,0.0f,0.0f,7.101041f,0.0f,
-3.402733f,7.101041f,0.0f,-3.236192f,7.101041f,1.051502f,0.0f,7.101041f,0.0f,
-3.236192f,7.101041f,1.051502f,-2.752869f,7.101041f,2.000076f,0.0f,7.101041f,0.0f,
-2.752869f,7.101041f,2.000076f,-2.000076f,7.101041f,2.752869f,0.0f,7.101041f,0.0f,
-2.000076f,7.101041f,2.752869f,-1.051502f,7.101041f,3.236191f,0.0f,7.101041f,0.0f,
-1.051502f,7.101041f,3.236191f,0.0f,7.101041f,3.402 733f,0.0f,7.101041f,0.0f,
0.0f,7.101041f,3.402733f,1.051502f,7.101041f,3.236 191f,0.0f,7.101041f,0.0f,
1.051502f,7.101041f,3.236191f,2.000076f,7.101041f, 2.752868f,0.0f,7.101041f,0.0f,
2.000076f,7.101041f,2.752868f,2.752868f,7.101041f, 2.000076f,0.0f,7.101041f,0.0f,
2.752868f,7.101041f,2.000076f,3.236191f,7.101041f, 1.051502f,0.0f,7.101041f,0.0f,
3.236191f,7.101041f,1.051502f,3.402732f,7.101041f, 0.0f,0.0f,7.101041f,0.0f,
3.402732f,7.101041f,0.0f,3.236193f,7.101041f,-1.051503f,0.0f,7.101041f,0.0f,
};

static GLfloat vt_triangles[] = {0.626409f,0.064408f,0.648603f,0.107966f,0.5f,0.15 f,
0.591842f,0.029841f,0.626409f,0.064408f,0.5f,0.15f ,
0.548284f,0.007647f,0.591842f,0.029841f,0.5f,0.15f ,
0.5f,0.0f,0.548284f,0.007647f,0.5f,0.15f,
0.451716f,0.007647f,0.5f,0.0f,0.5f,0.15f,
0.408159f,0.029841f,0.451716f,0.007647f,0.5f,0.15f ,
0.373591f,0.064409f,0.408159f,0.029841f,0.5f,0.15f ,
0.351397f,0.107966f,0.373591f,0.064409f,0.5f,0.15f ,
0.34375f,0.15625f,0.351397f,0.107966f,0.5f,0.15f,
0.351397f,0.204534f,0.34375f,0.15625f,0.5f,0.15f,
0.373591f,0.248091f,0.351397f,0.204534f,0.5f,0.15f ,
0.408159f,0.282659f,0.373591f,0.248091f,0.5f,0.15f ,
0.451716f,0.304853f,0.408159f,0.282659f,0.5f,0.15f ,
0.5f,0.3125f,0.451716f,0.304853f,0.5f,0.15f,
0.548284f,0.304853f,0.5f,0.3125f,0.5f,0.15f,
0.591841f,0.282659f,0.548284f,0.304853f,0.5f,0.15f ,
0.626409f,0.248091f,0.591841f,0.282659f,0.5f,0.15f ,
0.648603f,0.204534f,0.626409f,0.248091f,0.5f,0.15f ,
0.65625f,0.15625f,0.648603f,0.204534f,0.5f,0.15f,
0.648603f,0.107966f,0.65625f,0.15625f,0.5f,0.15f,
0.648603f,0.892034f,0.626409f,0.935591f,0.5f,0.837 5f,
0.626409f,0.935591f,0.591841f,0.970159f,0.5f,0.837 5f,
0.591841f,0.970159f,0.548284f,0.992353f,0.5f,0.837 5f,
0.548284f,0.992353f,0.5f,1.0f,0.5f,0.8375f,
0.5f,1.0f,0.451716f,0.992353f,0.5f,0.8375f,
0.451716f,0.992353f,0.408159f,0.970159f,0.5f,0.837 5f,
0.408159f,0.970159f,0.373591f,0.935591f,0.5f,0.837 5f,
0.373591f,0.935591f,0.351397f,0.892034f,0.5f,0.837 5f,
0.351397f,0.892034f,0.34375f,0.84375f,0.5f,0.8375f ,
0.34375f,0.84375f,0.351397f,0.795466f,0.5f,0.8375f ,
0.351397f,0.795466f,0.373591f,0.751909f,0.5f,0.837 5f,
0.373591f,0.751909f,0.408159f,0.717341f,0.5f,0.837 5f,
0.408159f,0.717341f,0.451716f,0.695147f,0.5f,0.837 5f,
0.451716f,0.695147f,0.5f,0.6875f,0.5f,0.8375f,
0.5f,0.6875f,0.548284f,0.695147f,0.5f,0.8375f,
0.548284f,0.695147f,0.591842f,0.717341f,0.5f,0.837 5f,
0.591842f,0.717341f,0.626409f,0.751908f,0.5f,0.837 5f,
0.626409f,0.751908f,0.648603f,0.795466f,0.5f,0.837 5f,
0.648603f,0.795466f,0.65625f,0.84375f,0.5f,0.8375f ,
0.65625f,0.84375f,0.648603f,0.892034f,0.5f,0.8375f ,
};

static GLfloat vn_triangles[] = {0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,1.0f,0.0f,
};

static GLfloat v_quads[] = {3.236193f,0.295577f,-1.051503f,2.75287f,0.295577f,-2.000077f,2.75287f,7.101041f,-2.000077f,3.236193f,7.101041f,-1.051503f,
2.75287f,0.295577f,-2.000077f,2.000077f,0.295577f,-2.75287f,2.000077f,7.101041f,-2.75287f,2.75287f,7.101041f,-2.000077f,
2.000077f,0.295577f,-2.75287f,1.051503f,0.295577f,-3.236192f,1.051503f,7.101041f,-3.236192f,2.000077f,7.101041f,-2.75287f,
1.051503f,0.295577f,-3.236192f,0.0f,0.295577f,-3.402734f,0.0f,7.101041f,-3.402734f,1.051503f,7.101041f,-3.236192f,
0.0f,0.295577f,-3.402734f,-1.051503f,0.295577f,-3.236192f,-1.051503f,7.101041f,-3.236192f,0.0f,7.101041f,-3.402734f,
-1.051503f,0.295577f,-3.236192f,-2.000077f,0.295577f,-2.752869f,-2.000077f,7.101041f,-2.752869f,-1.051503f,7.101041f,-3.236192f,
-2.000077f,0.295577f,-2.752869f,-2.752869f,0.295577f,-2.000076f,-2.752869f,7.101041f,-2.000076f,-2.000077f,7.101041f,-2.752869f,
-2.752869f,0.295577f,-2.000076f,-3.236192f,0.295577f,-1.051502f,-3.236192f,7.101041f,-1.051502f,-2.752869f,7.101041f,-2.000076f,
-3.236192f,0.295577f,-1.051502f,-3.402733f,0.295577f,0.0f,-3.402733f,7.101041f,0.0f,-3.236192f,7.101041f,-1.051502f,
-3.402733f,0.295577f,0.0f,-3.236192f,0.295577f,1.051502f,-3.236192f,7.101041f,1.051502f,-3.402733f,7.101041f,0.0f,
-3.236192f,0.295577f,1.051502f,-2.752869f,0.295577f,2.000076f,-2.752869f,7.101041f,2.000076f,-3.236192f,7.101041f,1.051502f,
-2.752869f,0.295577f,2.000076f,-2.000076f,0.295577f,2.752869f,-2.000076f,7.101041f,2.752869f,-2.752869f,7.101041f,2.000076f,
-2.000076f,0.295577f,2.752869f,-1.051502f,0.295577f,3.236191f,-1.051502f,7.101041f,3.236191f,-2.000076f,7.101041f,2.752869f,
-1.051502f,0.295577f,3.236191f,0.0f,0.295577f,3.402 733f,0.0f,7.101041f,3.402733f,-1.051502f,7.101041f,3.236191f,
0.0f,0.295577f,3.402733f,1.051502f,0.295577f,3.236 191f,1.051502f,7.101041f,3.236191f,0.0f,7.101041f, 3.402733f,
1.051502f,0.295577f,3.236191f,2.000076f,0.295577f, 2.752868f,2.000076f,7.101041f,2.752868f,1.051502f, 7.101041f,3.236191f,
2.000076f,0.295577f,2.752868f,2.752868f,0.295577f, 2.000076f,2.752868f,7.101041f,2.000076f,2.000076f, 7.101041f,2.752868f,
2.752868f,0.295577f,2.000076f,3.236191f,0.295577f, 1.051502f,3.236191f,7.101041f,1.051502f,2.752868f, 7.101041f,2.000076f,
3.236191f,0.295577f,1.051502f,3.402732f,0.295577f, 0.0f,3.402732f,7.101041f,0.0f,3.236191f,7.101041f, 1.051502f,
3.402732f,0.295577f,0.0f,3.236193f,0.295577f,-1.051503f,3.236193f,7.101041f,-1.051503f,3.402732f,7.101041f,0.0f,
};

static GLfloat vt_quads[] = {0.375f,0.3125f,0.3875f,0.3125f,0.3875f,0.68844f,0 .375f,0.68844f,
0.3875f,0.3125f,0.4f,0.3125f,0.4f,0.68844f,0.3875f ,0.68844f,
0.4f,0.3125f,0.4125f,0.3125f,0.4125f,0.68844f,0.4f ,0.68844f,
0.4125f,0.3125f,0.425f,0.3125f,0.425f,0.68844f,0.4 125f,0.68844f,
0.425f,0.3125f,0.4375f,0.3125f,0.4375f,0.68844f,0. 425f,0.68844f,
0.4375f,0.3125f,0.45f,0.3125f,0.45f,0.68844f,0.437 5f,0.68844f,
0.45f,0.3125f,0.4625f,0.3125f,0.4625f,0.68844f,0.4 5f,0.68844f,
0.4625f,0.3125f,0.475f,0.3125f,0.475f,0.68844f,0.4 625f,0.68844f,
0.475f,0.3125f,0.4875f,0.3125f,0.4875f,0.68844f,0. 475f,0.68844f,
0.4875f,0.3125f,0.5f,0.3125f,0.5f,0.68844f,0.4875f ,0.68844f,
0.5f,0.3125f,0.5125f,0.3125f,0.5125f,0.68844f,0.5f ,0.68844f,
0.5125f,0.3125f,0.525f,0.3125f,0.525f,0.68844f,0.5 125f,0.68844f,
0.525f,0.3125f,0.5375f,0.3125f,0.5375f,0.68844f,0. 525f,0.68844f,
0.5375f,0.3125f,0.55f,0.3125f,0.55f,0.68844f,0.537 5f,0.68844f,
0.55f,0.3125f,0.5625f,0.3125f,0.5625f,0.68844f,0.5 5f,0.68844f,
0.5625f,0.3125f,0.575f,0.3125f,0.575f,0.68844f,0.5 625f,0.68844f,
0.575f,0.3125f,0.5875f,0.3125f,0.5875f,0.68844f,0. 575f,0.68844f,
0.5875f,0.3125f,0.6f,0.3125f,0.6f,0.68844f,0.5875f ,0.68844f,
0.6f,0.3125f,0.6125f,0.3125f,0.6125f,0.68844f,0.6f ,0.68844f,
0.6125f,0.3125f,0.625f,0.3125f,0.625f,0.68844f,0.6 125f,0.68844f,
};

static GLfloat vn_quads[] = {0.951057f,0.0f,-0.309016f,0.809017f,0.0f,-0.587785f,0.809017f,0.0f,-0.587785f,0.951057f,0.0f,-0.309016f,
0.809017f,0.0f,-0.587785f,0.587785f,0.0f,-0.809017f,0.587785f,0.0f,-0.809017f,0.809017f,0.0f,-0.587785f,
0.587785f,0.0f,-0.809017f,0.309017f,0.0f,-0.951057f,0.309017f,0.0f,-0.951057f,0.587785f,0.0f,-0.809017f,
0.309017f,0.0f,-0.951057f,0.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.309017f,0.0f,-0.951057f,
0.0f,0.0f,-1.0f,-0.309017f,0.0f,-0.951057f,-0.309017f,0.0f,-0.951057f,0.0f,0.0f,-1.0f,
-0.309017f,0.0f,-0.951057f,-0.587785f,0.0f,-0.809017f,-0.587785f,0.0f,-0.809017f,-0.309017f,0.0f,-0.951057f,
-0.587785f,0.0f,-0.809017f,-0.809017f,0.0f,-0.587785f,-0.809017f,0.0f,-0.587785f,-0.587785f,0.0f,-0.809017f,
-0.809017f,0.0f,-0.587785f,-0.951056f,0.0f,-0.309017f,-0.951056f,0.0f,-0.309017f,-0.809017f,0.0f,-0.587785f,
-0.951056f,0.0f,-0.309017f,-1.0f,0.0f,0.0f,-1.0f,0.0f,0.0f,-0.951056f,0.0f,-0.309017f,
-1.0f,0.0f,0.0f,-0.951057f,0.0f,0.309017f,-0.951057f,0.0f,0.309017f,-1.0f,0.0f,0.0f,
-0.951057f,0.0f,0.309017f,-0.809017f,0.0f,0.587785f,-0.809017f,0.0f,0.587785f,-0.951057f,0.0f,0.309017f,
-0.809017f,0.0f,0.587785f,-0.587785f,0.0f,0.809017f,-0.587785f,0.0f,0.809017f,-0.809017f,0.0f,0.587785f,
-0.587785f,0.0f,0.809017f,-0.309017f,0.0f,0.951056f,-0.309017f,0.0f,0.951056f,-0.587785f,0.0f,0.809017f,
-0.309017f,0.0f,0.951056f,0.0f,0.0f,1.0f,0.0f,0.0f, 1.0f,-0.309017f,0.0f,0.951056f,
0.0f,0.0f,1.0f,0.309017f,0.0f,0.951057f,0.309017f, 0.0f,0.951057f,0.0f,0.0f,1.0f,
0.309017f,0.0f,0.951057f,0.587785f,0.0f,0.809017f, 0.587785f,0.0f,0.809017f,0.309017f,0.0f,0.951057f,
0.587785f,0.0f,0.809017f,0.809017f,0.0f,0.587785f, 0.809017f,0.0f,0.587785f,0.587785f,0.0f,0.809017f,
0.809017f,0.0f,0.587785f,0.951057f,0.0f,0.309017f, 0.951057f,0.0f,0.309017f,0.809017f,0.0f,0.587785f,
0.951057f,0.0f,0.309017f,1.0f,0.0f,1E-06f,1.0f,0.0f,1E-06f,0.951057f,0.0f,0.309017f,
1.0f,0.0f,1E-06f,0.951057f,0.0f,-0.309016f,0.951057f,0.0f,-0.309016f,1.0f,0.0f,1E-06f,
};

glVertexPointer(3, GL_FLOAT, 0, v_triangles);
glTexCoordPointer(2, GL_FLOAT, 0, vt_triangles);
glNormalPointer(GL_FLOAT, 0, vn_triangles);
if(glLockArraysEXT!=NULL) {glLockArraysEXT (0,120);}
glDrawArrays(GL_TRIANGLES, 0, 120);
if(glUnlockArraysEXT!=NULL) {glUnlockArraysEXT();}

glVertexPointer(3, GL_FLOAT, 0, v_quads);
glTexCoordPointer(2, GL_FLOAT, 0, vt_quads);
glNormalPointer(GL_FLOAT, 0, vn_quads);
if(glLockArraysEXT!=NULL) {glLockArraysEXT (0,80);}
glDrawArrays(GL_QUADS, 0, 80);
if(glUnlockArraysEXT!=NULL) {glUnlockArraysEXT();}




/*

PFNGLLOCKARRAYSEXTPROC glLockArraysEXT = NULL;
PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT = NULL;

void LoadExtensions()
{
int IsSupported;

IsSupported=isExtensionSupported("GL_EXT_compiled_vertex_array");
if(IsSupported)
{
glLockArraysEXT = ( PFNGLLOCKARRAYSEXTPROC ) wglGetProcAddress ("glLockArraysEXT");
glUnlockArraysEXT = ( PFNGLUNLOCKARRAYSEXTPROC ) wglGetProcAddress ("glUnlockArraysEXT");

if((glLockArraysEXT==NULL)||(glUnlockArraysEXT==NU LL))
{
AffMessageGL("Erreur EXT",COLOR_JAUNE,10);
}
}
}

thokra
12-27-2011, 02:18 AM
i have to convert .obj(cylinder model) to c++/opengl

*smart-ass mode on* First of all, C++ is a standardized programmaing language, OpenGL is a specification and OpenGL implementations are usually (if not generally) written in C and have a C-API. *smart-ass mode off*

What do you mean, you're not able to edit that code?

designer_2011
12-27-2011, 02:33 AM
hi thokra,

my process is:

1. import 3d model into opengl/c++
2. find the vertex and movement

now i can import 3d model into opengl/c++, but i can't find the vertex point, so i used obj to opengl/c++ code, but i could n't able to understand "static GLfloat v_triangles[]", below sample code(3d cube) i can understand. how to give v_triangles[] values.

#include <GL/glut.h>

GLfloat light_diffuse[] = {1.0, 0.0, 0.0, 1.0}; /* Red diffuse light. */
GLfloat light_position[] = {1.0, 1.0, 1.0, 0.0}; /* Infinite light location. */
GLfloat n[6][3] = { /* Normals for the 6 faces of a cube. */
{-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0},
{0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0} };
GLint faces[6][4] = { /* Vertex indices for the 6 faces of a cube. */
{0, 1, 2, 3}, {3, 2, 6, 7}, {7, 6, 5, 4},
{4, 5, 1, 0}, {5, 6, 2, 1}, {7, 4, 0, 3} };
GLfloat v[8][3]; /* Will be filled in with X,Y,Z vertexes. */

void
drawBox(void)
{
int i;

for (i = 0; i < 6; i++) {
glBegin(GL_QUADS);
glNormal3fv(&amp;n[i][0]);
glVertex3fv(&amp;v[faces[i][0]][0]);
glVertex3fv(&amp;v[faces[i][1]][0]);
glVertex3fv(&amp;v[faces[i][2]][0]);
glVertex3fv(&amp;v[faces[i][3]][0]);
glEnd();
}
}

void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
drawBox();
glutSwapBuffers();
}

void
init(void)
{
/* Setup cube vertex data. */
v[0][0] = v[1][0] = v[2][0] = v[3][0] = -1;
v[4][0] = v[5][0] = v[6][0] = v[7][0] = 1;
v[0][1] = v[1][1] = v[4][1] = v[5][1] = -1;
v[2][1] = v[3][1] = v[6][1] = v[7][1] = 1;
v[0][2] = v[3][2] = v[4][2] = v[7][2] = 1;
v[1][2] = v[2][2] = v[5][2] = v[6][2] = -1;

/* Enable a single OpenGL light. */
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);

/* Use depth buffering for hidden surface elimination. */
glEnable(GL_DEPTH_TEST);

/* Setup the view of the cube. */
glMatrixMode(GL_PROJECTION);
gluPerspective( /* field of view in degree */ 40.0,
/* aspect ratio */ 1.0,
/* Z near */ 1.0, /* Z far */ 10.0);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */
0.0, 0.0, 0.0, /* center is at (0,0,0) */
0.0, 1.0, 0.); /* up is in positive Y direction */

/* Adjust cube position to be asthetic angle. */
glTranslatef(0.0, 0.0, -1.0);
glRotatef(60, 1.0, 0.0, 0.0);
glRotatef(-20, 0.0, 0.0, 1.0);
}

int
main(int argc, char **argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("red 3D lighted cube");
glutDisplayFunc(display);
init();
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}


thanks

thokra
12-27-2011, 04:11 AM
Well, if you don't know what


static GLfloat v_triangles[] = {...};

does, then the first and best way to go is to read a tutorial on C++.

Just to be clear, you don't need to intizialize the array v_triangles since the OBJ->C++ converter already does that for you. Ask yourself the question, why you would want to manually edit the dataset if all the data you need is already how you want it.

Furthermore, the first piece of code uses vertex arrays whereas your second code uses immediate mode commands. You should read up on vertex array to understand what the first code does.

Tazeg
01-20-2012, 05:45 AM
I added a VC++ sample project on :
http://www.jeffprod.com/obj2opengl.php?setlang=en

V-man
01-20-2012, 06:55 AM
That glLockArraysEXT stuff is ancient. That was back in 1995.