0
\$\begingroup\$

I'm working with the Cen64 emulator and I compiled from source a x86 version that operates fine on Windows 10 x64. As soon as I run it on a Windows XP x86 machine the colors are then all incorrect. Here are some screenshots:

Running on Win 10 good rendering Running on Win XP SP3 bad rendering
The color format is set to GL_UNSIGNED_SHORT_5_5_5_1 and the internal format is GL_RGBA:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, hres + hskip, vres,
    0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, buffer);

I'm pretty new to configuring color packing formats but it appears like some color channels are getting swapped? Maybe some sort of endianness issue going from an x64 to an x86 architecture?

Please let me know if I need to show more of my code to help debug the issue. Thanks for any help! ^_^

\$\endgroup\$
4
  • \$\begingroup\$ OpenGL is not dependent on OS, it is dependent on your GPU and driver. \$\endgroup\$ Jan 20, 2019 at 22:06
  • \$\begingroup\$ @MaximusMinimus True. I forgot to mention that on the XP machine the version of opengl it's using is 2.1. Maybe there's an incompatible extension being used since the emulator was really designed to be run on current operating systems. \$\endgroup\$
    – CalebHC
    Jan 20, 2019 at 22:36
  • \$\begingroup\$ ... And the hardware is? \$\endgroup\$ Jan 21, 2019 at 6:48
  • 1
    \$\begingroup\$ Windows XP? Really? \$\endgroup\$
    – 3Dave
    Feb 18, 2020 at 18:46

1 Answer 1

1
\$\begingroup\$

Got the issue finally sorted. I'm probably wrong but I think there's a bug in my old OpenGL 2.1 driver that is not setting the byte swapping for the frame buffer: https://github.com/n64dev/cen64/blob/b27960c94f9f4d5997fc2b64a76fb30e79b13be4/vi/render.c#L46

I fixed by just manually rolling my own byte swapper and now all is good! ^_^ https://github.com/deadcast2/cen64/blob/cd8ae9c48a150d0b9121d4c38a82ea019680b4f4/vi/controller.c#L135

// Do a manual byte swap since a bug in opengl 2.1 driver
uint8_t *frame_buffer = vi->window->frame_buffer;
for (size_t i = 0; i < copy_size; i += 2) {
  uint16_t color = frame_buffer[i] | (frame_buffer[i + 1] << 8);
  frame_buffer[i] = color >> 8;
  frame_buffer[i + 1] = color;
}

Happy pipe now :D

fixed

\$\endgroup\$
2
  • 4
    \$\begingroup\$ First, please don't post pictures of source code. Just copy and paste the 5 relevant lines. Second, you can swap the bytes by just using a temporary variable: uint8_t temp = framebuffer[i]; framebuffer[i] = framebuffer[i + 1]; framebuffer[i + 1] = temp; Much easier to read than a bunch of shifts. If you're using C++, just use std::swap(framebuffer[i], framebuffer[i + 1]);. \$\endgroup\$ Jan 24, 2019 at 5:32
  • \$\begingroup\$ Why did you post screenshot of the code? Was it for any copyright reason? \$\endgroup\$ Jan 24, 2019 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .