kandi background
Explore Kits

lwjgl3-generated | LWJGL 3 - Generated Sources

 by   LWJGL Java Version: Current License: No License

 by   LWJGL Java Version: Current License: No License

Download this library from

kandi X-RAY | lwjgl3-generated Summary

lwjgl3-generated is a Java library. lwjgl3-generated has no bugs, it has no vulnerabilities and it has low support. However lwjgl3-generated build file is not available. You can download it from GitHub.
LWJGL 3 - Generated Sources
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • lwjgl3-generated has a low active ecosystem.
  • It has 12 star(s) with 4 fork(s). There are 7 watchers for this library.
  • It had no major release in the last 12 months.
  • lwjgl3-generated has no issues reported. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of lwjgl3-generated is current.
lwjgl3-generated Support
Best in #Java
Average in #Java
lwjgl3-generated Support
Best in #Java
Average in #Java

quality kandi Quality

  • lwjgl3-generated has 0 bugs and 0 code smells.
lwjgl3-generated Quality
Best in #Java
Average in #Java
lwjgl3-generated Quality
Best in #Java
Average in #Java

securitySecurity

  • lwjgl3-generated has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • lwjgl3-generated code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
lwjgl3-generated Security
Best in #Java
Average in #Java
lwjgl3-generated Security
Best in #Java
Average in #Java

license License

  • lwjgl3-generated does not have a standard license declared.
  • Check the repository for any license declaration and review the terms closely.
  • Without a license, all rights are reserved, and you cannot use the library in your applications.
lwjgl3-generated License
Best in #Java
Average in #Java
lwjgl3-generated License
Best in #Java
Average in #Java

buildReuse

  • lwjgl3-generated releases are not available. You will need to build from source code and install.
  • lwjgl3-generated has no build file. You will be need to create the build yourself to build the component from source.
lwjgl3-generated Reuse
Best in #Java
Average in #Java
lwjgl3-generated Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed lwjgl3-generated and discovered the below as its top functions. This is intended to give you an instant insight into lwjgl3-generated implemented functionality, and help decide if they suit your requirements.

  • Returns the elements of a transform type .
    • Set the values from a VkInstance .
      • Creates a printable callback .
        • Destroy all resources .
          • Save an EXR image to a file .
            • Gets the perf query id by name .
              • Decode a filename from a file .
                • Initialise callback callback .
                  • Set a setting string .
                    • VSS function .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      lwjgl3-generated Key Features

                      LWJGL 3 - Generated Sources

                      Community Discussions

                      Trending Discussions on lwjgl3-generated
                      • Translating C library to Java: Getting mangled garbage data in top-left of resulting bitmap
                      Trending Discussions on lwjgl3-generated

                      QUESTION

                      Translating C library to Java: Getting mangled garbage data in top-left of resulting bitmap

                      Asked 2018-Jan-02 at 09:40

                      The LWJGL3 library contains bindings to STB TrueType and other libraries made by Sean Barrett.

                      In order to modify the packing API provided by this library to render SDF glyphs into the backing texture instead of normal bitmaps, I am reproducing the texture-rendering code from the library in java.

                      I managed to get it to almost work but I am hitting a stumbling stone where I am getting mangled garbage data for the very top-left corner of the texture. I am somewhat confident that the error must be located somewhere in the code for my version of the stbtt__h_prefilter(...), as this is where the assertion fails.

                      Edit: I forgot to take into consideration the current buffer position when doing read/write operations on the buffer. Now I still have some garbage data in the bitmap, but it's more evenly distributed.

                      In fact looking at the updated second picture it seems that somehow the very left-most part of every glyph is shifted half the glyph height down. I cannot find out where or why it happens, especially considering that the bitmap processing works on each glyph individually after it is rendered into the font, so to my understanding the next line of glyphs should just overwrite this..?

                      Bitmap generated by the original library: Correct bitmap

                      Bitmap generated by my version (see the offset half-lines cutting into some letters): Mangled bitmap

                      Addendum: Bitmap generated by my version without the prefilter_... methods: Unfiltered bitmap

                      Below you find my versions of the methods from the library. The originals can be found here.


                      The references to STB... functions refer to the generated bindings form lwjgl3.

                      private static boolean packFontRangesRenderIntoRectsSDF(
                                        STBTTPackContext context, STBTTFontinfo fontinfo,
                                        STBTTPackRange.Buffer ranges, STBRPRect.Buffer rects) {
                      
                          int i, j, k;
                          boolean returnValue = true;
                      
                          int curr_hOversample = context.h_oversample();
                          int curr_vOversample = context.v_oversample();
                      
                          k = 0;
                          for(i = 0 ; i < ranges.remaining() ; i++) {
                              float fh = ranges.get(i).font_size();
                              float scale = fh > 0.0f ? stbtt_ScaleForPixelHeight(fontinfo, fh) : stbtt_ScaleForMappingEmToPixels(fontinfo, -fh);
                              float recip_h, recip_v, sub_x, sub_y;
                      
                              curr_hOversample = STBTTPackRange.nh_oversample(ranges.get(i).address()) & 0xFF;
                              curr_vOversample = STBTTPackRange.nv_oversample(ranges.get(i).address()) & 0xFF;
                      
                              recip_h = 1.0f / (float)curr_hOversample;
                              recip_v = 1.0f / (float)curr_vOversample;
                      
                              sub_x = __oversample_shift(curr_hOversample);
                              sub_y = __oversample_shift(curr_vOversample);
                      
                              for(j = 0 ; j < ranges.get(i).num_chars() ; j++) {
                                  STBRPRect r = rects.get(k);
                                  if(r.was_packed()) {
                                      STBTTPackedchar bc = ranges.get(i).chardata_for_range().get(j);
                      
                                      IntBuffer advance = ByteBuffer.allocateDirect(Integer.BYTES)
                                                                    .order(ByteOrder.nativeOrder())
                                                                    .asIntBuffer();
                                      IntBuffer lsb = ByteBuffer.allocateDirect(Integer.BYTES)
                                                                .order(ByteOrder.nativeOrder())
                                                                .asIntBuffer();
                      
                                      IntBuffer x0 = ByteBuffer.allocateDirect(Integer.BYTES)
                                                               .order(ByteOrder.nativeOrder())
                                                               .asIntBuffer();
                                      IntBuffer x1 = ByteBuffer.allocateDirect(Integer.BYTES)
                                                               .order(ByteOrder.nativeOrder())
                                                               .asIntBuffer();
                                      IntBuffer y0 = ByteBuffer.allocateDirect(Integer.BYTES)
                                                               .order(ByteOrder.nativeOrder())
                                                               .asIntBuffer();
                                      IntBuffer y1 = ByteBuffer.allocateDirect(Integer.BYTES)
                                                               .order(ByteOrder.nativeOrder())
                                                               .asIntBuffer();
                      
                                      int codepoint = ranges.get(i).array_of_unicode_codepoints() == null ? ranges.get(i).first_unicode_codepoint_in_range() + j : ranges.get(i).array_of_unicode_codepoints().get(j);
                                      int glyph = stbtt_FindGlyphIndex(fontinfo, codepoint);
                                      int pad = context.padding();
                      
                                      r.x((short) (r.x() + pad));
                                      r.y((short) (r.y() + pad));
                                      r.w((short) (r.w() - pad));
                                      r.h((short) (r.h() - pad));
                                      stbtt_GetGlyphHMetrics(fontinfo, glyph, advance, lsb);
                                      stbtt_GetGlyphBitmapBox(fontinfo, glyph,
                                                              scale * curr_hOversample,
                                                              scale * curr_vOversample,
                                                              x0, y0, x1, y1);
                                      //TODO replace below with SDF func
                                      ByteBuffer buff = context.pixels(context.height() * context.width());
                                      buff.position(r.x() + r.y() * context.stride_in_bytes());
                      
                                      stbtt_MakeGlyphBitmapSubpixel(fontinfo, buff,
                                                                    r.w() - curr_hOversample + 1,
                                                                    r.h() - curr_vOversample + 1,
                                                                    context.stride_in_bytes(),
                                                                    scale * curr_hOversample,
                                                                    scale * curr_vOversample,
                                                                    0, 0,
                                                                    glyph);
                      
                                      if(curr_hOversample > 1) {
                                          //FIXME __h_prefilter(..) function
                                          buff.position(r.x() + r.y() * context.stride_in_bytes());
                                          __h_prefilter(buff,
                                                        r.w(), r.h(), context.stride_in_bytes(),
                                                        curr_hOversample);
                                      }
                      
                                      if(curr_vOversample > 1) {
                                          //FIXME __v_prefilter(..) function
                                          buff.position(r.x() + r.y() * context.stride_in_bytes());
                                          __v_prefilter(buff,
                                                        r.w(), r.h(), context.stride_in_bytes(),
                                                        curr_vOversample);
                                      }
                      
                                      bc.x0(r.x());
                                      bc.y0(r.y());
                                      bc.x1((short) (r.x() + r.w()));
                                      bc.y1((short) (r.y() + r.h()));
                                      bc.xadvance(scale * advance.get(0));
                                      bc.xoff((float) (x0.get(0) * recip_h + sub_x));
                                      bc.yoff((float) (y0.get(0) * recip_v + sub_y));
                                      bc.xoff2((x0.get(0) + r.w()) * recip_h + sub_x);
                                      bc.yoff2((y0.get(0) + r.h()) * recip_v + sub_y);
                                  } else {
                                      returnValue = false;
                                  }
                      
                                  ++k;
                              }
                          }
                      
                          return returnValue;
                      }
                      
                      //copy of stbtt__oversample_shift(..) as it's inaccessible
                      private static float __oversample_shift(int oversample) {
                          if(oversample == 0) {
                              return 0.0f;
                          }
                      
                          return (float)-(oversample - 1) / (2.0f * (float)oversample);
                      }
                      
                      private static final int MAX_OVERSAMPLE = 8;
                      private static final int __OVER_MASK = MAX_OVERSAMPLE - 1;
                      
                      private static void __h_prefilter(ByteBuffer pixels, int w, int h, int stride_in_bytes, int kernel_width) {
                          final int pixels_offset = pixels.position();
                          int pixelstride = 0;
                      
                          byte[] buffer = new byte[MAX_OVERSAMPLE];
                          int safe_w = w - kernel_width;
                          int j;
                      
                          Arrays.fill(buffer, 0, MAX_OVERSAMPLE, (byte)0);
                      
                          for(j = 0 ; j < h ; j++) {
                              int i;
                              int total;
                              Arrays.fill(buffer, 0, kernel_width, (byte)0);
                      
                              total = 0;
                      
                              for(i = 0 ; i <= safe_w ; i++) {
                                  total += Byte.toUnsignedInt(pixels.get(pixels_offset + (pixelstride + i))) - Byte.toUnsignedInt(buffer[i & __OVER_MASK]);
                                  buffer[(i + kernel_width) & __OVER_MASK] = pixels.get(pixels_offset + (pixelstride + i));
                                  pixels.put(pixels_offset + (pixelstride + i), (byte) Integer.divideUnsigned(total, kernel_width));
                              }
                      
                              for(; i < w ; ++i) {
                      //                if(Byte.toUnsignedInt(pixels.get(pixels_offset + (pixelstride + i))) != 0) {
                      //                    throw new RuntimeException("Expected '0' but was '" + Byte.toUnsignedInt(pixels.get(pixels_offset + (pixelstride + i))) + "'");
                      //                }
                      
                                  total -= Byte.toUnsignedInt(buffer[i & __OVER_MASK]);
                                  pixels.put(pixels_offset + (pixelstride + i), (byte) Integer.divideUnsigned(total, kernel_width));
                              }
                      
                              pixelstride += stride_in_bytes;
                          }
                      }
                      
                      private static void __v_prefilter(ByteBuffer pixels, int w, int h, int stride_in_bytes, int kernel_width) {
                          final int pixels_offset = pixels.position();
                          int pixelstride = 0;
                      
                          byte[] buffer = new byte[MAX_OVERSAMPLE];
                          int safe_h = h - kernel_width;
                          int j;
                          Arrays.fill(buffer, 0, MAX_OVERSAMPLE, (byte)0);
                      
                          for(j = 0 ; j < w ; j++) {
                              int i;
                              int total;
                              Arrays.fill(buffer, 0, kernel_width, (byte)0);
                      
                              total = 0;
                      
                              for(i = 0 ; i <= safe_h ; i++) {
                                  total += Byte.toUnsignedInt(pixels.get(pixels_offset + ((pixelstride + i) * stride_in_bytes))) - Byte.toUnsignedInt(buffer[i & __OVER_MASK]);
                                  buffer[(i + kernel_width) & __OVER_MASK] = pixels.get(pixels_offset + ((pixelstride + i) * stride_in_bytes));
                                  pixels.put(pixels_offset + ((pixelstride + i) * stride_in_bytes), (byte) Integer.divideUnsigned(total, kernel_width));
                              }
                      
                              for(; i < h ; ++i) {
                      //                if(Byte.toUnsignedInt(pixels.get(pixels_offset + ((pixelstride + i) * stride_in_bytes))) != 0) {
                      //                    throw new RuntimeException("Expected '0' but was '" + Byte.toUnsignedInt(pixels.get(pixels_offset + ((pixelstride + i) * stride_in_bytes))) + "'");
                      //                }
                      
                                  total -= Byte.toUnsignedInt(buffer[i & __OVER_MASK]);
                                  pixels.put(pixels_offset + ((pixelstride + i) * stride_in_bytes), (byte) Integer.divideUnsigned(total, kernel_width));
                              }
                      
                              pixelstride += 1;
                          }
                      }
                      

                      ANSWER

                      Answered 2018-Jan-02 at 09:40

                      It seems to work out fine when I remove the offset from the __v_prefilter(..) method.

                      Thus changing final int pixels_offset = pixels.position(); to final int pixels_offset = 0; (or removing it altogether from the code).

                      I say it seems because I have not done any bitwise comparisons of the produced maps between my, now working, and the original code. There are just no, to me at least, discernible mangled bits in the texture anymore.

                      Source https://stackoverflow.com/questions/48022431

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install lwjgl3-generated

                      You can download it from GitHub.
                      You can use lwjgl3-generated like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the lwjgl3-generated component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Java Libraries
                      Try Top Libraries by LWJGL
                      Compare Java Libraries with Highest Support
                      Compare Java Libraries with Highest Quality
                      Compare Java Libraries with Highest Security
                      Compare Java Libraries with Permissive License
                      Compare Java Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.