Trying to Pivote/Rotate matrix/view?


Have been trying for a while now to do this, but it doesn’t seem to be working as I wish:

I have the following points (as an example);
The lower the z value here the more accurate what I’m trying to do becomes. So the coordinates get displayed but on a slight angle, so I’m obviously missing something I just don’t know what :sorrow:.

I currently have a top-overview of this (on a different context & have no issue), but I’m trying to get a cross section view, which I thought using Rotate on the X-axis 90degrees would work, but :(…
Following code is an extract of what I’m using, if it isn’t enough let me know & I’ll have to post more:

	//prepare scene
	m_ModelMatrix = IDENTITY_MATRIX;
	m_ProjectionMatrix = IDENTITY_MATRIX;
	m_ViewMatrix = IDENTITY_MATRIX;
	RotateAboutX(&m_ModelMatrix,90); //have also tried using this after Translate
	ScaleMatrix(&m_ViewMatrix, m_ScaleX, m_ScaleY, m_ScaleZ); //scales cords x,y,z
	TranslateMatrix(&m_ViewMatrix, 0, 0, m_TranslateZ); //

	glViewport(0, 0, (GLsizei)cx, (GLsizei)cy);
	//fovy is 60. Have tried others.
	m_ProjectionMatrix = CreateProjectionMatrix(m_fovy,(float)CurrentWidth / CurrentHeight,1.0f,100.0f);

	//have also tried rotating here.
	glUniformMatrix4fv(m_ModelMatrixUniformLocation, 1, GL_FALSE, m_ModelMatrix.m);
	glUniformMatrix4fv(m_ViewMatrixUniformLocation, 1, GL_FALSE, m_ViewMatrix.m);
	glDrawArrays(DRAW_TYPE, 0,;

	const GLchar* VertexShader = 
		"#version 330
		"layout(location=0) in vec4 in_Position;
		"layout(location=1) in vec4 in_Color;
		"out vec4 ex_Color;
		"uniform mat4 vsModelMatrix;
		"uniform mat4 vsViewMatrix;
		"uniform mat4 vsProjectionMatrix;
		"void main(void)
			"gl_Position = (vsProjectionMatrix * vsViewMatrix * vsModelMatrix) * in_Position;
			"ex_Color = in_Color;

Any insight would be much appreciated!
Thank you.

I have not seens the whole code but just a first few lines and I find that probably ur transformation sequence is wrong.
Usually for a matrix library doing post multiplication (right handed as in OpenGL fixed function pipeline), the sequence of transformation is this

(Translate * ( Rotate * Scale))

that is to say you apply scaling first then rotation and finally translation. Doing it with fixed function pipeline will be something like this


//your glVertex etc. calls here

This will be called in the reverse order on the vertice/s, scaling first then rotation and finally translation.

See if this helps.

I don’t know how the code you’ve posted translates into modern OpenGL :confused:.
I am a beginner. I have searched & read so much, but as per my problem above explains it’s not working how I want & I really don’t know why.

All I want to do is view these coordinates on the screen in 2D, but from side on (or rather, a different angle to their natural state). Where would I find a fully working example that does this that doesn’t use depreciated code & doesn’t use GLM :dejection:.

glm is the latest extension tool for modern OpenGL; it provides a standard library of matrix and vectors to make code sharing easier hence more and more tutorials are using it. If you don’t want to use it or depreciated code, it will be harder for you to find tutorials.

It is not an “extension tool”. It’s not even “for OpenGL”. It’s just a vector math library. More tutorials are using it because it’s simple to use and it works, which up until GLM hasn’t really been true of vector math libraries.

It’s not even “for OpenGL”

This is true but it does have a lot of functions that are replacements for OpenGL glu functions that other vector libraries don’t have.