I’m using GLFW on MacOS and I’m using some OpenGL calls to draw an image in the window. For some reason, glDrawPixels(…) isn’t filling the window. This is what I have:
#define IMAGE_WIDTH 800
#define IMAGE_HEIGHT 600
int main(int argc, const char * argv[])
{
GLFWwindow* window;
int nx = IMAGE_WIDTH;
int ny = IMAGE_HEIGHT;
// One time during setup.
unsigned int data[ny][nx][3];
for( size_t y = 0; y < ny; ++y )
{
for( size_t x = 0; x < nx; ++x )
{
data[y][x][0] = ( rand() % 256 ) * 256 * 256 * 256;
data[y][x][1] = 0;
data[y][x][2] = 0;
}
}
// Initialize the library
if (!glfwInit())
return -1;
/* Create a windowed mode window and its OpenGL context */
window = glfwCreateWindow(nx, ny, "FOO", NULL, NULL);
if (!window)
{
glfwTerminate();
return -1;
}
/* Make the window's context current */
glfwMakeContextCurrent(window);
/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
/* Render here */
glClear(GL_COLOR_BUFFER_BIT);
glDrawPixels( nx, ny, GL_RGB, GL_UNSIGNED_INT, data );
/* Swap front and back buffers */
glfwSwapBuffers(window);
/* Poll for and process events */
glfwPollEvents();
}
glfwTerminate();
return 0;
}
I’ve tried to make it as clear as possible. The window dimensions and the pixel data should be based off the same provided dimensions, so it’s a little unclear to me why it seems to only fill a quarter of the screen. Here is a screencap of the window: https://imgur.com/4kbFzij