Author Topic: Cpct?  (Read 1095 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #30 on: November 19, 2019, 12:53:53 pm »
Yeah, but Primitives don't really have proper texture coordinates. That's the point of ExtendedPrimitives. I suggest to port that too to have something that helps to limit the possible problem sources.

Offline AGP

  • quad
  • ******
  • Posts: 1638
    • View Profile
Re: Cpct?
« Reply #31 on: November 20, 2019, 01:33:54 am »
OK, done. Same thing: single-colored textures work, images don't (and the images aren't null, either).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #32 on: November 20, 2019, 10:31:07 am »
Then either your loading/conversion of the texture is wrong or your texture coordinates are. I tend to the former, because that's more likely to get broken in porting then some simple floats that should behave the same in both languages.

Offline AGP

  • quad
  • ******
  • Posts: 1638
    • View Profile
Re: Cpct?
« Reply #33 on: November 20, 2019, 07:37:24 pm »
Loading an image is a simple call to Image.FromFile(filename). Which leaves us the texture coordinates. Would that be in Object3D?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12011
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #34 on: November 21, 2019, 11:19:31 am »
Loading an image is a simple call to Image.FromFile(filename). Which leaves us the texture coordinates. Would that be in Object3D?
Are you sure? Loading is one thing, but you have to make an int[]-array out of the loaded image. I would rather think that this step is wrong.

Offline AGP

  • quad
  • ******
  • Posts: 1638
    • View Profile
Re: Cpct?
« Reply #35 on: November 21, 2019, 07:26:03 pm »
I applied my ReverseBytes to the texels and still got black. Actually, at first I got fully-transparent, then I switched the bitwise OR for a bitwise AND for alpha as follows and I was back to black.

Code: [Select]
private static System.UInt32 ReverseBytes(System.UInt32 value) {
    value = (value & 255);//MAKE OPAQUE IT's AN OR IN SoftGLRenderer. WHY?
    return (value & 0x000000FFU) << 24 | (value & 0x0000FF00U) << 8 | (value & 0x00FF0000U) >> 8 | (value & 0xFF000000U) >> 24;
}
    }

Offline AGP

  • quad
  • ******
  • Posts: 1638
    • View Profile
Re: Cpct?
« Reply #36 on: November 22, 2019, 08:30:37 am »
You're a good man, Egon. You were right, the texels[] were black. I'm forced to use the following rather slow nested loop, but voilá, it works.

I think that I'm going to tackle a skeletal structure for it before I try my hand at a hardware renderer, but the eventual C# hardware renderer will benefit from direct access to OpenGL.

Code: [Select]
    int i = 0;
    for (int y = 0; y < image.Height; y++)
for (int x = 0; x < image.Width; x++)
     texels[i++] = (uint) image.GetPixel(x, y).ToArgb();