Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (799)
Games in Android Showcase (236)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: deepthought (posted 2015-06-30 15:39:44, viewed 435 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82  
package SPAGE.engine.gui;

import static org.lwjgl.opengl.GL11.GL_ALPHA;
import static org.lwjgl.opengl.GL11.GL_BLUE;
import static org.lwjgl.opengl.GL11.GL_GREEN;
import static org.lwjgl.opengl.GL11.GL_LINEAR;
import static org.lwjgl.opengl.GL11.GL_RED;
import static org.lwjgl.opengl.GL11.GL_RGBA;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_MAG_FILTER;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_MIN_FILTER;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_BYTE;
import static org.lwjgl.opengl.GL11.glBindTexture;
import static org.lwjgl.opengl.GL11.glGenTextures;
import static org.lwjgl.opengl.GL11.glTexSubImage2D;
import static org.lwjgl.opengl.GL33.GL_TEXTURE_SWIZZLE_RGBA;

import java.nio.ByteBuffer;
import java.nio.IntBuffer;

import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;

import SPAGE.engine.gui.glStagePlatform.texupdater;

public class subimageupdater implements texupdater {
   glStagePlatform plat;
   ByteBuffer buf;
   
   int tex;
   int width, height;
   
   public int setup(int w, int h) {
      
      width=w;
      height=h;
      
      tex=glGenTextures();
      glBindTexture(GL_TEXTURE_2D, tex);
      
      
      System.out.println(width+" "+height);
      
      GL11.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,(ByteBuffer)null);
      
      
      GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
      GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      
      
      int[] swizzlemask={GL_GREEN,GL_BLUE,GL_ALPHA,GL_RED};
      IntBuffer swizzlebuf = BufferUtils.createIntBuffer(swizzlemask.length);
      swizzlebuf.put(swizzlemask);
      swizzlebuf.rewind();
      GL11.glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzlebuf);
      
      buf=ByteBuffer.allocateDirect(width*height*4);
      
      return tex;
   }

   public void update() {
      glBindTexture(GL_TEXTURE_2D, tex);
      buf.rewind();
      plat.getPixels(buf.asIntBuffer(), width, height);
      buf.rewind();
      glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_RGBA,GL_UNSIGNED_BYTE,buf);
   }

   public void giveplatform(glStagePlatform p) {
      plat=p;
   }

   public void resize(int w, int h) {
      
      width=w;height=h;
      buf=ByteBuffer.allocateDirect(w*h*4);
      GL11.glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,(ByteBuffer)null);
      
   }

}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
Riven (185 views)
2019-09-04 15:33:17

hadezbladez (4863 views)
2018-11-16 13:46:03

hadezbladez (1785 views)
2018-11-16 13:41:33

hadezbladez (5135 views)
2018-11-16 13:35:35

hadezbladez (1015 views)
2018-11-16 13:32:03

EgonOlsen (4367 views)
2018-06-10 19:43:48

EgonOlsen (5215 views)
2018-06-10 19:43:44

EgonOlsen (2945 views)
2018-06-10 19:43:20

DesertCoockie (3867 views)
2018-05-13 18:23:11

nelsongames (4293 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!