Good afternoon, I am from Maracaibo-Venezuela and I’m working in my thesis. The work has become difficult because I am new in Java, but I must work obligatorily in it.
I have been trying to texture for a long time and I have not been able to do it. I am working with client server; previously the server passed the data of the image to the client (as soon as the client him towards the request by all means), it means, the components of each pixel, DID NOT WORK to ME, now what I am doing or trying to do is to pass the image like so to the client and disturbing it thence, it means, to obtain in the client the components of each pixel and those components to keep them in an adjustment soon to pass to it to opengl. It didn’t work, I think there is something wrong in my code.
the code of the client or part of it is here below:
try
{
Socket socket = new Socket(servidor, puerto);
ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
MensajeDameFichero mensaje = new MensajeDameFichero();
mensaje.nombreFichero = fichero;
oos.writeObject(mensaje);
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
[glow=red,2,300]FileInputStream fis = new FileInputStream(mensaje.nombreFichero);
final BufferedImage bi = ImageIO.read(fis);
final BufferedImage bfi = new BufferedImage(bi.getWidth(),bi.getHeight(),BufferedImage.TYPE_INT_RGB);
Graphics2D big = bfi.createGraphics();
big.drawImage(bi, 0, 0, new escenarioGLEvenListener());[/glow]
MensajeTomaFichero mensajeRecibido;
Object mensajeAux;
ColorModel color;
int r, g, b, x, y,i=0;
int ancho = bi.getWidth();
int alto = bi.getHeight();
int cant=0;
int[] losBytes = new int[ancho*alto*3];
color = bfi.getColorModel();
for(x=0; x<ancho; x++)
{
for(y=0; y<alto; y++)
{
r = color.getRed(bfi.getRGB(x,y));
losBytes[i]=r;
g = color.getGreen(bfi.getRGB(x,y));
losBytes[i+1]=g;
b = color.getBlue(bfi.getRGB(x,y));
losBytes[i+2]=b;
i+=3;
cant++;
}
}
ois.close();
socket.close();
} catch (Exception e)
{
e.printStackTrace();
}
Luego le paso a opengl el arreglo “losBytes”:
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, 64, 64, 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, losBytes);
Que sucede??