Package fcagnin.jglsdk.glimg.ImageSet

Examples of fcagnin.jglsdk.glimg.ImageSet.Dimensions


    return dds10header;
  }
 
 
  private static Dimensions getDimensions(DdsHeader ddsHeader) {
    Dimensions ddsDimensions = new Dimensions();
    ddsDimensions.numDimensions = 1;
    ddsDimensions.width = ddsHeader.width;
   
    if ((ddsHeader.flags & DdsFlags.HEIGHT) != 0) {
      ddsDimensions.numDimensions = 2;
View Full Code Here


      return lineWidth * bytesPerPixel;
    }
  }
 
  private static int calcMipmapSize(UncheckedImageFormat ddsFormat, Dimensions ddsDimensions, int mipmapLevel) {
    Dimensions mipmapDimensions = Util.calcMipmapLevelDimensions(ddsDimensions, mipmapLevel);
    int lineSize = calcLineSize(ddsFormat, mipmapDimensions.width);

    int effectiveHeight = 1;
    if (mipmapDimensions.numDimensions > 1) {
      effectiveHeight = mipmapDimensions.height;
View Full Code Here

*/
class ImageCreator {
 
  ImageCreator(ImageFormat ddsFormat, Dimensions ddsDimensions, int mipmapCount, int arrayCount, int faceCount) {
    m_imageFormat = ddsFormat;
    m_imageDimensions = new Dimensions(ddsDimensions);
   
    m_mipmapCount = mipmapCount;
    m_arrayCount = arrayCount;
    m_faceCount = faceCount;

    if (faceCount != 6 && faceCount != 1) {
      throw new BadFaceCountException();
    }

    if (faceCount == 6 && ddsDimensions.numDimensions != 2) {
      throw new CubemapsMustBe2DException();
    }

    if (ddsDimensions.numDimensions == 3 && arrayCount != 1) {
      throw new No3DTextureArrayException();
    }

    if (mipmapCount <= 0 || arrayCount <= 0) {
      throw new NoImagesSpecifiedException();
    }
   
    m_imageData = new ArrayList<>(mipmapCount);
    m_imageSizes = new int[mipmapCount];
   
    // Allocate the memory for our data.
    for (int mipmapLevel = 0; mipmapLevel < mipmapCount; mipmapLevel++) {
      Dimensions mipmapLevelDimensions = Util.calcMipmapLevelDimensions(ddsDimensions, mipmapLevel);
     
      int mipmapLevelSize = Util.calcMipmapLevelSize(ddsFormat, mipmapLevelDimensions);
      m_imageSizes[mipmapLevel] = mipmapLevelSize;

      byte[] mipmapLevelData = new byte[mipmapLevelSize * faceCount * arrayCount];   
 
View Full Code Here

   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

  private void copyImageFlipped(byte[] sourceData, byte[] imageData, int imageDataOffset, int mipmapLevel) {   
    assert (sourceData.length * m_faceCount * m_arrayCount) == imageData.length;
   
    Dimensions mipmapImageDimensions = Util.calcMipmapLevelDimensions(new Dimensions(m_imageDimensions), mipmapLevel);
   
    if (m_imageFormat.getPixelDataType().ordinal() < PixelDataType.NUM_UNCOMPRESSED_TYPES.ordinal()) {
      copyPixelsFlipped(m_imageFormat,
          sourceData, imageData, imageDataOffset,
          m_imageSizes[mipmapLevel], mipmapImageDimensions);
View Full Code Here

        try {
            String filePath = Framework.findFileOrThrow( "gamma_ramp.png" );
            ImageSet imageSet = StbLoader.loadFromFile( filePath );

            SingleImage image = imageSet.getImage( 0, 0, 0 );
            Dimensions imageDimensions = image.getDimensions();

            OpenGLPixelTransferParams pxTrans = TextureGenerator.getUploadFormatType( imageSet.getFormat(), 0 );

            glBindTexture( GL_TEXTURE_2D, textures[0] );
View Full Code Here

            linearTexture = glGenTextures();
            glBindTexture( GL_TEXTURE_2D, linearTexture );

            for ( int mipmapLevel = 0; mipmapLevel < imageSet.getMipmapCount(); mipmapLevel++ ) {
                SingleImage image = imageSet.getImage( mipmapLevel, 0, 0 );
                Dimensions imageDimensions = image.getDimensions();

                glTexImage2D( GL_TEXTURE_2D, mipmapLevel, GL_SRGB8, imageDimensions.width, imageDimensions.height, 0,
                        GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, image.getImageData() );
            }

            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0 );
            glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, imageSet.getMipmapCount() - 1 );


            filePath = Framework.findFileOrThrow( "checker_gamma.dds" );
            imageSet = DdsLoader.loadFromFile( filePath );

            gammaTexture = glGenTextures();
            glBindTexture( GL_TEXTURE_2D, gammaTexture );

            for ( int mipmapLevel = 0; mipmapLevel < imageSet.getMipmapCount(); mipmapLevel++ ) {
                SingleImage image = imageSet.getImage( mipmapLevel, 0, 0 );
                Dimensions imageDimensions = image.getDimensions();

                glTexImage2D( GL_TEXTURE_2D, mipmapLevel, GL_SRGB8, imageDimensions.width, imageDimensions.height, 0,
                        GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, image.getImageData() );
            }
View Full Code Here

            OpenGLPixelTransferParams xfer = TextureGenerator.getUploadFormatType( imageSet.getFormat(), 0 );

            for ( int mipmapLevel = 0; mipmapLevel < imageSet.getMipmapCount(); mipmapLevel++ ) {
                SingleImage image = imageSet.getImage( mipmapLevel, 0, 0 );
                Dimensions imageDimensions = image.getDimensions();

                glTexImage2D( GL_TEXTURE_2D, mipmapLevel, GL_SRGB8_ALPHA8, imageDimensions.width,
                        imageDimensions.height, 0, xfer.format, xfer.type, image.getImageData() );
            }
View Full Code Here

TOP

Related Classes of fcagnin.jglsdk.glimg.ImageSet.Dimensions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.