Note that there are some explanatory texts on larger screens.

plurals
  1. POBlended textures show up fine, but ordinary coloured shapes do not
    text
    copied!<p>For some reason enabling alpha blending results in me not being able to draw run-of-the-mill coloured shapes. The order in which everything is drawn makes no difference. Even if the only thing being drawn is the coloured shape, it still won't show.</p> <p>Disabling alpha blending fixes this, but disables alpha blending (obviously). This leads me to believe the problem is in how I'm initializing openGL.</p> <p>The textured objects are contained in the world, which is commented out. Commenting "world.run();" out makes no difference, only disabling alpha blending does.</p> <pre><code>public class Core { int width=800, height=600; //World world; public void Start(){ try { Display.setDisplayMode(new DisplayMode(width,height)); Display.create(); } catch (LWJGLException e) { e.printStackTrace(); System.exit(0); } initGL(); System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)); boolean Close = Display.isCloseRequested(); //world = new World(width, height); while(!Close){ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) || Display.isCloseRequested()) Close = true; //world.run(); GL11.glColor4d(1, 0, 0, 1); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2d(0, 0); GL11.glVertex2d(0, 50); GL11.glVertex2d(50, 50); GL11.glVertex2d(50, 0); GL11.glEnd(); Display.update(); //Display.sync(60); } } public void initGL(){ GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); // enable alpha blending GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glViewport(0,0,width,height); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, width, height, 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); } public static void main(String args[]){ Core m = new Core(); m.Start(); } </code></pre> <p>}</p> <p>This is for a 2D app where I'm trying to draw metaballs behind the texture of a black-and-white world map.</p> <p>Run-of-the-mill coloured shapes refers to the following,</p> <pre><code>GL11.glColor4d(1, 0, 0, 1); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2d(0, 0); GL11.glVertex2d(0, 50); GL11.glVertex2d(50, 50); GL11.glVertex2d(50, 0); GL11.glEnd(); </code></pre> <p>Even if drawn on its own, as long as alpha blending is enabled, it won't show up.</p> <p>UPDATE: The constructor for <em>world</em> was loading (but not drawing) a texture. Removing that part of the code lets the coloured square show up. I have deduced that the problem will occur as long as a texture is loaded, regardless of whether it is displayed or not.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload