Jump to content

Particles with generated textures


rich1051414

Recommended Posts

Ok, so I have particle effects that have their own texture file, and on top of that, the texture file is generated at startup and only the opengl reference ID is kept. So far, I haven't even found a way to hook a physical file, let alone simply an int id. This is what I am doing now:

public void renderParticle(...)
//...rendering variable initialization and calculations here

par1Tessellator.draw(); //to flush the tessalator

//Do all my GL11_ calls directly here, including color setting, using the tesselators api here usually doesnt work after a flush.
GL11.glBindTexture(GL11.GL_TEXTURE_2D, MyIntGL11BoundTextureID); //to get the integer id with assembled BufferedImages, do a renderEngine.allocateAndSetupTexture(BufferedImage)

par1Tessellator.startDrawingQuads();

par1Tessellator.addVertexWithUV(...);
par1Tessellator.addVertexWithUV(...);
par1Tessellator.addVertexWithUV(...);
par1Tessellator.addVertexWithUV(...);

//Now flush reset settings, and restart the quad drawing.
par1Tessellator.draw();
//Reset all GL_ settings back to their originals
GL11.glBindTexture(GL11.GL_TEXTURE_2D, renderEngine.getTexture("/gui/items.png"));
par1Tessellator.startDrawingQuads();

That method works... mostly, except we are flushing the tesselators buffer that is not full, and it causes some really odd things to happen. Using layer 2 reduces this to a minimum, but it can still cause oddities, like missing colors/flickering colors. I could also choose not to flush before the tesselation, but this causes even worse issues, my texture leaking into other effects.

 

Does anyone know of a better way to do this, or some calls I might be missing? I currently only set the basics, blendfunc, color4f and depthtest(requires a flush unless you are on acid). If anyone has any info let me know, right now I am just trying to keep the problems at a minimum by  flushing before and after my rendering.

Link to comment
Share on other sites

Did you look at normal particle code? They have icon index stuff in there to use a physical file in there

What kind of question is that? Are you going to ask me if my computer is plugged in? God, its tech support all over again. -_-

 

Btw, I figured it out, at least, what seems to work for me. If you make all your GL11 calls after you draw+startDrawingQuads(), then reset them after your final draw and before the final startDrawingQuads(), the color loss doesn't seem to happen, at least not for me.  Maybe that can help another with a similar problem. Also it seems to help to do a GL11 color call AND a tesselator color call, in case colordisabled is set, setting one or the other doesn't seem to be 100%

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.