hello,
I use this chunk of code for setup a windows for opengl 3.3:
HWND CreateAppWindow(const WNDCLASSEX &wcl, const char *pszTitle)
{
// Create a window that is centered on the desktop. It's exactly 1/4 the
// size of the desktop. Don't allow it to be resized.
DWORD wndExStyle = WS_EX_OVERLAPPEDWINDOW;
DWORD wndStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
HWND hWnd = CreateWindowEx
(wndExStyle, wcl.lpszClassName, "title",
wndStyle, 0, 0, 0, 0, 0, 0, wcl.hInstance, 0);
if (hWnd)
{
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
int halfScreenWidth = screenWidth / 2;
int halfScreenHeight = screenHeight / 2;
int left = (screenWidth - halfScreenWidth) / 2;
int top = (screenHeight - halfScreenHeight) / 2;
RECT rc = {0};
SetRect(&rc, left, top, left + halfScreenWidth, top + halfScreenHeight);
AdjustWindowRectEx(&rc, wndStyle, FALSE, wndExStyle);
MoveWindow(hWnd, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
GetClientRect(hWnd, &rc);
m_windowWidth = rc.right - rc.left;
m_windowHeight = rc.bottom - rc.top;
}
return hWnd;
};
The problem is that i can’t understand how the vbo vertexes are related to the window.
For example i use these points:
-1.0, -1.0, 0.5;
-1.0 , 1.0, 0.5;
1.0, 1.0, 0.5;
and i use this two shaders:
vshader:
i set the uniform mat4 MVP to identity
#version 330
in vec3 VertexPosition;
uniform mat4 MVP;
void main()
{
gl_Position = MVP * vec4( VertexPosition, 1.0 );
}
and this fragment shader(the uniform vec4 color is set corrected by my project:
#version 330
out vec4 outputColor;
uniform vec4 color;
void main()
{
outputColor = color;
}
I think that the vbo data is from -1 to 1, the problem is that the triangle is not correct, it must be the half of the screen but it isn’t, is more smaller.
How i can create a triangle that is half of the entire screen ? and how are related the vbo vertexes to the width and height of the screen?
my goal is be able to set the entire coordinate for example 800 if the width of the screen is 800 ecc…
is possible?
my viewport recreated always in the render loop is
glViewport(0.0, 0.0, 800, 600);
thanks.