PDA

View Full Version : What is wrong with my openGL draw code?


sabungero
10-20-2011, 01:28 PM
https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s320x320/305826_10150328713781911_715076910_8695877_564572531_n.jpg

Hello, what is wrong with my openGL code? I am suspecting it to be my push and popAttrib codes. As you can see, the wireframe is not showing at all when the object is covered behind the custom openGL locator. Any hints?

glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
glFT.glPushAttrib(OpenMayaRender.MGL_ALL_ATTRIB_BITS)

# some code is inserted here

glFT.glPopAttrib()
glFT.glPopAttrib()

the above draw codes are my settings for the glPushAttrib...

Thanks in advance...

Azrail
10-21-2011, 10:55 AM
Actually i'ts not shown only for the objects that seem to me are polygons, the cone which looks like is a NURBS is showing fine... so I guess may be there is something else, connected to the way your graphics driver handles OGL transparency connected with the way Maya draws polygon edges....

sabungero
10-21-2011, 02:15 PM
Actually i'ts not shown only for the objects that seem to me are polygons, the cone which looks like is a NURBS is showing fine... so I guess may be there is something else, connected to the way your graphics driver handles OGL transparency connected with the way Maya draws polygon edges....

i see, i will have somebody else test the code on a quadro card. this is very irritating,specially for animators who would like to see the deformation. i do not want them to be turning off the locator's visibility just so that they can see the deformation of the mesh. thank you very much

has anybody experienced the same thing?

sabungero
10-22-2011, 02:55 PM
OK, now i have just discovered that even joints are also hidden when overlapped by the custom locators...

whisperwing
10-25-2011, 07:16 AM
Out of curiosity I created a transparent cube with red lambert shader and placed it in a similar location. (See attachment, hopefully it loaded correctly). It seems normal to me, so I'm curious if you could just try to do that on your machine to rule out the possibility that your problem was due to the locator drawing code.

sabungero
10-26-2011, 08:39 AM
Hello, sir. I tried it out of curiosity, and it seems to be the same as your result...there is definitely something in my openGL draw codes that I did not understand fully, it could probably the MGL_BLEND, or that I have put lineWidth in the wrong order, I dont know...I will check my earlier codes to see where it started or if the problem was already there since the start. anyway, here is part of the code:

view.beginGL()

glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
glFT.glPushAttrib(OpenMayaRender.MGL_ALL_ATTRIB_BITS)

glFT.glEnable(OpenMayaRender.MGL_BLEND)

if status == OpenMayaUI.M3dView.kLead:
glFT.glColor4f(0.0+color_RVal, 0.0+color_GVal, 0.0+color_BVal, 0.2)
if status == OpenMayaUI.M3dView.kActive:
glFT.glColor4f(0.0+color_RVal+.3, 0.0+color_GVal+.3, 0.0+color_BVal+.3, 0.2)
if status == OpenMayaUI.M3dView.kDormant:
glFT.glColor4f(0.0+color_RVal-.3, 0.0+color_GVal-.3, 0.0+color_BVal-.3, 0.4)

glFT.glBegin(OpenMayaRender.MGL_QUADS)

#some openGL primitive draw codes#

glFT.glEnd()

glFT.glLineWidth(widthVal)

glFT.glBegin(OpenMayaRender.MGL_LINE_STRIP)

#some openGL primitive draw codes#

glFT.glEnd()

glFT.glDisable(OpenMayaRender.MGL_BLEND)

glFT.glPopAttrib()
glFT.glPopAttrib()
view.endGL()

Azrail
10-26-2011, 01:32 PM
Straight from the OGL FAQ (http://www.opengl.org/resources/faq/technical/transparency.htm) - try adding this lines (can't test this right now):

glEnable (GL_BLEND)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)


of course you should convert them to python api calls ;)

sabungero
10-26-2011, 02:02 PM
amazing! thank you very much,i will try to read this later after my game of starcraft. i was looking for this reference but i cannot seem to find it using google. i learned the basics of OGL's class,methods and functions through another site. thank you very much again.

CGTalk Moderation
10-26-2011, 02:02 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.