PDA

View Full Version : Using 2D and 3D at the same time



cairnswm
09-05-2004, 06:50 AM
I want to create a game that uses a model for the game animations and 2D from the user interface and interactions.

In my render function I have tried

Begin2D
Draw 2D things
End2D
Begin3D
Draw 3D models
End3D
Begin2D
Draw 2D things
End2D

The items in the first 2D drawing block as well as those in the second 2D drawing block are drawn in what looks like an alpha drawn state. I have tried to change the background behind them before drawing but it makes no difference.

How do I mix 2D and 3D things together?

Abened
09-05-2004, 08:30 AM
I think you're doing it the good way, even if I would begin by drawing the 3D scene and then add the 2D part, because it's possible the 2D items you drawed first will be overlapped by the 3D elements.

Secondly, for you stange drawn state, perhaps you forgot to set UseColor(1,1,1) before drawing, because the 2D sprite colors are modified by the UseColor value (for example if you set UseColor(1,0,0), only the red part of the sprite will be visible).
Are you sure you didn't enable alpha blending ? (this is done by glEnable(GL_BLEND), and by choosing a blending mode : glBlendFunc(...,...) ). If this is the case, i could be the reason of the odd drawing...

Abened

cairnswm
10-05-2004, 05:35 AM
Thanks. There are some 2D items I want to be overwritten by the 3D things.

I havn't used the setColor option at all. I'll try do as you suggest and see what happens.

I have not added any straight openGL calls (thats why I'm using GLXTreem - so I dont need to learn the OpenGL stuff :) ).

cairnswm
13-05-2004, 11:09 AM
The UseColor(1,1,1) idea didn't fix the problem.

I'll load my program and source onto the internet later and ask for some help. If possible I'll do it tonight.