# How can switch GLSL “version #120” to “version #330”?

I am using GLSL "version #120" and i want to change it with "version #330". I added "GLM" library for this purpose. But i have some problems. Therefore i will ask you what is equal to this setting ?

My version #120 init():

glMatrixMode(GL_PROJECTION);
gluPerspective(45,aspectRatio, 1, 1000);
glMatrixMode(GL_MODELVIEW);


My version #120 draw():

glClearColor(0.5,0.5,0.5,1.0);
//-------Camera--------
glRotatef(-camPitch,1.0,0.0,0.0);
glRotatef(-camYaw,0.0,1.0,0.0);
glTranslatef(-CamLoc.x,-CamLoc.y,-CamLoc.z);

//----Objects---------
glPushMatrix();
glTranslatef(obje_1LocX,obje_1LocY,obje_1LocZ);
drawObject_1();
glPopMatrix();

glPushMatrix();
glTranslatef(obje_2LocX,obje_2LocY,obje_2LocZ);
drawObject_2();
glPopMatrix();
....
....etc


Also one mini question. Can I continue using glPushMatrix() and glPopMatrix() at "version #330" ?

EDIT : I did it, i think. But is it good setup ?

i delete codes inside init() and it is my new draw() function:

glClearColor(0.0,1.0,1.0,1.0);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

glUseProgram(program3);
glm::mat4 projection = glm::perspective(glm::radians(45.0f), 1280.0f / 720.0f , 0.1f, 10000.0f);
//------Camera----------
glm::mat4 view = glm::lookAt(
glm::vec3(0,120,-1000), // Camera is at (4,3,3), in World Space
glm::vec3(0,0,0), // and looks at the origin
glm::vec3(0,1,0)  // Head is up (set to 0,-1,0 to look upside-down)
);

glm::mat4 model = glm::mat4(1.0f);

glm::mat4 MVP = projection * view * model;

int mvpIndex = glGetUniformLocation(program3, "MVP");
glUniformMatrix4fv(mvpIndex, 1, GL_FALSE, glm::value_ptr(MVP));

//----Objects---------

drawObject_1(); // it will be drawing at origin right ?

//----And i want to draw second object at x=400 y=0 z=0-----
model = glm::translate(model, glm::vec3( 400.0f,  0.0f,  0.0f) );

MVP = projection * view * model;
mvpIndex = glGetUniformLocation(program3, "MVP");
glUniformMatrix4fv(mvpIndex, 1, GL_FALSE, glm::value_ptr(MVP));

drawObject_2(); // it will be drawing at x= 400.0f y=0 z=0 right ?

glUseProgram(0);

• If you have a solution, feel free to post it as an answer. If you're not satisfied with your solution, try editing your question to call out what specific problem you're having with it that you need help overcoming. – DMGregory Nov 22 '18 at 23:42