Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[resolved] Opengl, texturing

I have created a cube which is textured, and I am calling this function to create different cubes.

One of these is a skybox, so the player sees the inside of the cube, this works perfectly.

Others are buildings and things, these end up looking like this: (the sky is the skybox)

boxtextures.png


The second texture is supposed to appear as a checkerboard - and it does when applied to the skybox:

boxtextures2.png


But remember, the skybox is just the same cube drawn larger so the player only sees the inside...

I'm wondering if anyone knows why, is there something obvious I'm missing as to why it only works on the inside of boxes?

This is the code for my cube:

C++:
 

//snip

Is there a flag or something I need to change to specify whether it's drawn on the inside or outside of the box? That's the only difference I can think of.

The skybox is drawn by:

drawBox(80, texName[2]);


The other boxes:

drawBox(1, texName[2]);
 
I feel stupid, but in case anybody else gets this problem, this is the solution:


In your draw method:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



In your init method:

glEnable(GL_DEPTH_TEST);


Google GL_DEPTH_TEST for settings you can apply to it.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top