Author Topic: Cpct?  (Read 4333 times)

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Cpct?
« on: September 16, 2019, 06:45:59 pm »
Now that even Excelsior Jet has been made extinct, how would you feel about making a c# version of jpct? At least the OpenGL bits would be better.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12047
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #1 on: September 21, 2019, 02:26:54 pm »
Well, I'm not interested in C# at all. As long as I don't have to use it (and I don't see why that would happen), I won't touch it.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #2 on: September 21, 2019, 07:07:51 pm »
Even with the Mono project (and, thus, being multi-platform)? How come? Now that there's no way to make machine code out of Java, I think that I may go with C#.
« Last Edit: September 21, 2019, 09:12:40 pm by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12047
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #3 on: September 23, 2019, 08:46:01 am »
I looked into it briefly, I found it like Java with some additional clutter on top, that doesn't really make it any better and it's Microsoft. I have nothing against Microsoft, but the community is strange. Whenever I had to deal with the community of a Microsoft product (the scripting language in Powershell is an example where I had to rely on it, VBA for Access another), it's somehow disappointing...I've noticed a pattern:

  • Java community: You usually get a solution or at least an idea pretty quickly. Sometimes is overly complicated, because Java people tend add layers of libs on top of each other, but you can ignore that most of the time.
  • Javascript community: Similar to Java, actually. Just more unorganized and more focused on the latest hot shit (i.e. not older than 2 weeks).
  • PHP community: You usually get a soution, but it often feels awkward and clunky, just like the language itself.
  • Microsoft community: One question, multiple solutions but none refers to the actual quesiton. But obviously that doesn't matter, because the poster of the question thanks them anyway.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #4 on: September 24, 2019, 02:20:37 am »
I have found every question I've ever had already asked and answered. I hope to be able to show something in the next few days.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #5 on: September 27, 2019, 05:25:51 pm »
I'm stuck in the FrameBuffer pixels thing. I found a way to do pretty much the same thing (https://stackoverflow.com/questions/1563038/fast-work-with-bitmaps-in-c-sharp), but pixels[] is too entrenched in the code.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #6 on: September 30, 2019, 08:48:05 pm »
Software renderer is compiled and running (not drawing anything yet, though).

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #7 on: November 05, 2019, 07:54:37 pm »
I even ported the loader. Everything's working except for the actual rendering (when I don't assign random colors to the polygons in SoftGLRenderer). In clearSoftware(Color col), I'm printing this: Logger.log("Coloring. Color: "+color +", Col: "+col.ToArgb());

And the result is: Coloring. Color: 16711680, Col: -65536

Could this be a byte order thing or is it just because the first integer doesn't hold the alpha?

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #8 on: November 06, 2019, 06:08:24 am »
Sure enough replacing pix=color; with pix=col.ToArgb(); started clearing. I'm now getting unshaded, untextured objects rendered against the appropriate color. Is my line much slower than your bit-shifting?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12047
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #9 on: November 06, 2019, 12:59:23 pm »
It's certainly slower. I'm not sure from where exactly this code snippet comes!? Is it inside the rendering loop or some loader/setup code. In case of the former, it might be critical.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #10 on: November 06, 2019, 03:47:44 pm »
It's in clearSoftware(Color).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12047
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #11 on: November 06, 2019, 08:45:20 pm »
I see. In that case, just move the call to col.ToArgb() out of the loop and assign the result, so that you don't have to do it thousands of times for frame.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #12 on: November 07, 2019, 03:38:08 am »
Done. But if the clear color was wrong, doesn't it follow that the texture-rendering stuff would be, as well (hence the unshaded sillouettes)? Put differently, where do I find the perspective-correct texture code in which to look for this issue?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12047
    • View Profile
    • http://www.jpct.net
Re: Cpct?
« Reply #13 on: November 07, 2019, 06:30:04 am »
In the SoftGLRenderer.

Offline AGP

  • quad
  • ******
  • Posts: 1639
    • View Profile
Re: Cpct?
« Reply #14 on: November 07, 2019, 06:49:05 am »
It's a bit hairy for me, since I don't really know what you're doing, but from what I gather alpha should be 24 bits shifted LEFT, red shifted 16 left, and so on. Is this line (under OptiZ) wrong (green is shifted by 8, then the whole thing gets shifted by 16)?
Code: [Select]
g=(((col>>8)&255)*(sgI>>10))>>16;