Author Topic: Cpct?  (Read 463 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12001
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #15 on: November 07, 2019, 10:33:48 am »
No, it's fine. It's some fixed point magix. You should be able to port that just at it is. Apart from that, your assumptions about the colors is correct. It's plain ARGB format.

Online AGP

  • quad
  • ******
  • Posts: 1629
    • View Profile
Re: Cpct?
« Reply #16 on: November 10, 2019, 08:22:45 pm »
I read somewhere that the bytes are flipped. So before drawing I'm trying to change them the following way. I get only a blank screen, once more.

Code: [Select]
private static System.UInt32 ReverseBytes(System.UInt32 value) {
    value += 4278190080;//MAKE OPAQUE; IS THIS RIGHT? (THAT'S 1111 1111 0000 0000 0000 0000 0000 0000)
    return (value & 0x000000FFU) << 24 | (value & 0x0000FF00U) << 8 | (value & 0x00FF0000U) >> 8 | (value & 0xFF000000U) >> 24;
}

Online AGP

  • quad
  • ******
  • Posts: 1629
    • View Profile
Re: Cpct?
« Reply #17 on: November 10, 2019, 08:47:30 pm »
Update. I'm now getting a pretty fast framerate and rendering solid, shaded but untextured objects. (I was adding to the wrong byte and it was just OR 255):
https://www.dropbox.com/s/638qg16adshb77d/screenFromSoftGLRenderer.png?dl=0

Code: [Select]
private static System.UInt32 ReverseBytes(System.UInt32 value) {
    value = (value | 255);//MAKE OPAQUE
    return (value & 0x000000FFU) << 24 | (value & 0x0000FF00U) << 8 | (value & 0x00FF0000U) >> 8 | (value & 0xFF000000U) >> 24;
}

If I call setTexture on this MD2, Darth Vader becomes unshaded and solid black.
« Last Edit: Today at 12:40:52 am by AGP »

Online AGP

  • quad
  • ******
  • Posts: 1629
    • View Profile
Re: Cpct?
« Reply #18 on: Today at 12:31:05 am »
Note: the following line produces, "Texture of polyID 1: DarthVader.png." And the texture was added to the TextureManager.

Code: [Select]
Logger.log("Texture of polyID 1: "+TextureManager.getInstance().getNameByID(sphere.getPolygonManager().getPolygonTexture(1)));

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12001
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #19 on: Today at 10:23:59 am »
I'm not sure about C#, but in Java, you have to handle the fact that the most significant bit of an int actually is the sign. So when shifting value & 0xff000000 down by 24, you have to remove the sign bit afterwards, because if not, you'll end up with some very different number from what you expect. See this test case:

Code: [Select]
public class ShiftTest
{
  public static void main(String[] args)
  {
    int value = 0xabcdef12;
    int cw = (value & 0x000000ff) << 24 | (value & 0x0000ff00) << 8 | (value & 0x00ff0000) >> 8 | (value & 0xff000000) >> 24;
    int cr = (value & 0x000000ff) << 24 | (value & 0x0000ff00) << 8 | (value & 0x00ff0000) >> 8 | ((value & 0xff000000) >> 24 & 0xff);
    System.out.println("wrong: "+Integer.toHexString(cw));
    System.out.println("correct: "+Integer.toHexString(cr));
  }
}

Maybe that's an issue here?

Online AGP

  • quad
  • ******
  • Posts: 1629
    • View Profile
Re: Cpct?
« Reply #20 on: Today at 03:58:02 pm »
I know that Java doesn't have them, but should I just make pixels[] uint or is there a scenario when they're supposed to be negative?