ok for one...
I must say I'm a noob at classes,
but have made some pretty good apps using nothing but functions.

I'd like to get into classes though, and every time I try,
I end up misunderstanding 1 or 2 things and messing the whole thing up... <:\

can I get some help with my current app though??
(I want it to be as conveinent as only 3 steps)

here's what it looks like:
http://lh5.ggpht.com/-dbdZVoXdr1s/TnOcWcOc7TI/AAAAAAAADg4/G2TI5DkvULQ/Universal%252520Model%252520Converter%252520v2.0.png
^(the GUI was made in MS paint... but that's the final look I want)

yes... it's a simple model converter...
(well... anything but simple)

the conversion methods update based on the plugins that are associated with the import and export filetypes
(since 2 or more plugins can associate with the... say .DAT format)

some data formats are so similarly different that a simple comparison won't work in certain circumstances.

anyways...
that aside, we have the plugin settings.
this was originally an idea for a popup GUI...
but certain realizations have changed it to using predefined classes for creating the buttons and widgets.
(instead of writing a ton of code for a single GUI)

a function will need to be provided for the class references for the GUI
(for both import and export)

so can I get some help?? (:>

if you have any Q's, feel free to ask :)

Recommended Answers

All 22 Replies

I am uniquely qualified then as I am also OO newbie, even maybe I manage sometimes hide it. Also I have not designed this kind of programs and plugin systems... well except yours, if you did not change it.

I think my mind would come to have ABC (Abstract Base Class) for base GUI and have each module use that by inheritance and add it's functionality.

I havn't changed your code by much :)
(you still get full credit for it) ;)

but yea... I only just figured out how it worked... >_>

heh... I still can't even put a for loop into single line form yet... *sighs in failure*

but yea...
this post is up for grabbs if anyone can help...

I'll study your reference a little more too...
thanx :)

I'm still worse than a class A noob at Tk
although I did manage to build a viewer for my model format >_>
(you have to wait about 16 seconds for the next frame... eh heh)

EDIT:

I can leave the plugin system (somewhat) as it is.
the functions for converting work just fine

it's the GUI functions that need to be redone...

the only other thing is...
I could never get the button window (for selecting the conversion method) to work.

the button window would appear, then disappear setting the value of the key to that of the last button's key value.
(if you click a button, it sets a key var and closes the window)

that wouldn't work as, for example, I had a DAT by Nintendo and a DAT by Microsoft.
(both were model files)
I had to switch the plugins out to convert between them.

uugh... stupid edit timer DX

anyways...
btw, about the way the conversion method feature acts now...

if you have no file selected, it's of course going to say 'Select File'
but if you have a file selected, and there's only 1 associated plugin,
it'll then have only 1 (disabled) option with the key text value
(if your input file is .OBJ, it'll say 'Wavefront')

only multi-reference conversion will give you selectible options.

JSYK, I've gotten alot of the basic file structure done and revamped everything...

and even put in backwards compatibility functions for my older plugins.

but I want to try dev-ing a GUI w/o using even Tkinter
any idea how to use the windows shell to define a custom GUI??

ok...
so in order to build the widgets I need...
first I need to understand what entirely you can do with a class.

and also how exactly to reference it for data handling to or from the class.

also...
may I ask you not reference me to anything unless it's simple enough to understand <:/

what I'm trying to say is, I have aspergurs syndrome <X(

but I want to try dev-ing a GUI w/o using even Tkinter

A book that is quite dated, but on the other hand probably inexpensive as a result, that describes how to access video memory and put pixels on the screen one at a time as any of the GUI tool kits like Tkinter do, is Herbert Schildt's "The Craft of C". Note that none of this is possible using Python, and even with C you have to drop down into assembly for the actual access to the video memory AFAIK, for security reasons among others. I have not had a desire to do any more of this since the age of GUI tool kits though.

A book that is quite dated, but on the other hand probably inexpensive as a result, that describes how to access video memory and put pixels on the screen one at a time as any of the GUI tool kits like Tkinter do, is Herbert Schildt's "The Craft of C". Note that none of this is possible using Python, and even with C you have to drop down into assembly for the actual access to the video memory AFAIK, for security reasons among others. I have not had a desire to do any more of this since the age of GUI tool kits though.

I just want to know how Tkinter.py
or even WX_Python does it >_>

it's obviously possible to do >_>
(WX doesn't use Tkinter)

actually...
screw that thought...
if blender can greate a GUI using OpenGL instead of shell gfx, then why can't I.
as using OGL even seems to be more efficient this way >:3

the Q is, how to do?? :/

note: I'd rather use OGL than DX
(if you know why then congrats to being a geek) ;)

an edit for my previous post:

please don't tell me to do any programming using PyOpenGL
as I'd have to download it.

this would mean I'd inconveinence everyone who wants my program byt DL-ing that library.

if the library's written in Py, how does it create the graphix??
that's what I want to do with my program.

alright...

so WX Python, PY GTK, and PYGame all seem to use the same method...

they all have an __init__.py module that imports sys, os, and string.

the libraries also include a few pyd files
for which I assume does the main work of drawing the GUI

I used WiiXplorer to look at their formatting,
and although I couldn't see much,
I could make out what 'MZ' was for, as 'MZÿÿ' seems to appear constantly in exe's
sadly the 'ÿÿ' is not recognized by WiiXplorer...
but I do have other text editors I could look at them with that do recognize those chars. >_>

...
hmm...
what if I integrate PyOpenGL with my app... >_>

then people won't have to install it :D

unless...
can you reference a DLL as a library with the installation??

I may have to UD to 3.x to do what I need >_>
(currently using 2.6)

sry...
I'm losing my train of thought...

so I have a few options:

1 - integrate PyOGL
2 - use the DLL's: GLU32, etc
3 - UD to 3.x if neccesary

what would be best??

well... since I'm not getting an answer, I guess I'll just use the DLL's...

actually...
integration is prbly more efficient...
so let's just integrate it then >_>

well...
integration went along better than expected :D

can't believe how not complicated it was

to use it I just have to put:

from data.OpenGL import *

or to import GLU

from data.OpenGL.GLU import *

sry...
mind my noobishism to new/unexpected python ways

can I get some help >_>
hopefully this will be simple...

can I get a class for an OGL button that's simple enough to be used in a var??

eg:

#referencing the Button class:
isEnabled,Text,X,Y = 1,'OK',10,10
button1 = Button( isEnabled, Text, X, Y )

the var 'button1' will be used in a function reguarding the button's callback

the button will also need to use a set of settings for a theme set...
(look at Blender's GUI for a good example of what I mean)

can someone work on a code to do just that plz :/
I can define the other classes I need using that class...
(I need to learn classes anyways, so this would be a good practise start)

well...
looks like I'm not getting any help here >_>


*sigh*

It's quite possible that is because people haven't used that or don't have much experience with it; it's not a matter of not wanting to help. Sometimes you just have to dig and dig to find you own answer, and I'm sure we'd be happy to see the result if you do.

It's quite possible that is because people haven't used that or don't have much experience with it; it's not a matter of not wanting to help. Sometimes you just have to dig and dig to find you own answer, and I'm sure we'd be happy to see the result if you do.

hmm... alright...

thanx for turning me around on this...
but this thread wasn't nearly as disappointing as the other users who could help me in this area >_>

the developers of Blender have done exactly what I want to do...
the only difference is the code, as their's is in C++
(I can't understand their code for crap) >_<

so I posted a topic in their developers corner for help with my GUI

I only got 1 reply in the past few weeks...
the rely was to reference me to a few toolkits which didn't do what I wanted...

well...
there was 1, but it dev'd in C++ >_>
I can't even get a working GUI in C++ other than the default GUI code it provides you with >.<

so that's how crappy I am at C++ XDD
I could do it in Py if I knew how to structure it >_>
but I'm being pushed for time as everyone keeps demanding me to finish it >.>
but then I get a few that say "take your time"

so anyways...
thanx again ;)

ok... so I've finally figured out a way to structure this
(thanx to a wiki page in C++)

the only problem I'm having now is transparency is not working >_>

import sys
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

def setup():
    glClearColor(0,0,0,0)

def display():
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    #draw stuff here:
    
    glColor4f(0.5, 0.5, 0.5, 0.8)
    glRectf(-0.75,0.75, 0.75, -0.75)
    
    glutSwapBuffers()

def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE)
    glutInitWindowSize(800,600)
    glutCreateWindow("Hello World")

    setup()
    glutDisplayFunc(display)

    glutMainLoop()

main()

does anyone have any hints or tips for me??
*sigh* I'm such a noob -_-*

well, I've started defining my GUI
(just got the top part of the option bar)

was testing the window resize options
[img]http://lh3.ggpht.com/-QyG4pN2GMZ4/TpiVW7g7-8I/AAAAAAAADkA/L4EIxBqq_oU/GUI%252520test1.PNG[/img]

the test failed:
[img]http://lh5.ggpht.com/-UNkbxCaG5BQ/TpiVY5vl-rI/AAAAAAAADkA/6xcrLnU_-Bo/GUI%252520test1%252520FAILED.PNG[/img]
the part of the bar is supposed to look exactly the same as in the first img >_>

if you'd like to see the GUI, you can check my post at KC-MM:
http://forums.kc-mm.com/index.php?topic=27625.msg711610#msg711610

img tags do not seem to exist but you can go to advanced editor and add picture as attachment to message from 'Attach files'.

alright...
redoing then... eh heh

well, I've started defining my GUI
(just got the top part of the option bar)

was testing the window resize options
[img]http://lh3.ggpht.com/-QyG4pN2GMZ4/TpiVW7g7-8I/AAAAAAAADkA/L4EIxBqq_oU/GUI%252520test1.PNG[/img]

the test failed:
[img]http://lh5.ggpht.com/-UNkbxCaG5BQ/TpiVY5vl-rI/AAAAAAAADkA/6xcrLnU_-Bo/GUI%252520test1%252520FAILED.PNG[/img]
the part of the bar is supposed to look exactly the same as in the first img >_>

if you'd like to see the GUI, you can check my post at KC-MM:
http://forums.kc-mm.com/index.php?topic=27625.msg711610#msg711610

it's still the same as of now >_>
(I've tried a resize function that doesn't seem to do anything)

width = 640
height = 480

def Xresize(ValX):
    if width == glutGet(GLUT_WINDOW_WIDTH): return ValX
    else: return ValX - ((1/(width-glutGet(GLUT_WINDOW_WIDTH)))*.001)

def Yresize(ValY): #does the same thing

I still get the same result :(

EDIT:
btw, transparency still doesn't work...
(it should be closer to black instead of gray)

can anyone here help me with getting transparency, antialize, and resize working as it should??

here's my current GUI progress:
http://forums.kc-mm.com/index.php?topic=27625.msg716174#msg716174
(yes I used blender to build the header bar/button (my code uses 1 as 3 bars))

I also need a callback for it to be used with other functions...

anyways, here's my code so far:

import sys
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

width,height = 640,480

def setup():
    glClearColor(0,0,0,0)

def HeaderBar(X1,X2,Y,Z):
    w = width-glutGet(GLUT_WINDOW_WIDTH)
    h = height-glutGet(GLUT_WINDOW_HEIGHT)

    #resize functions:
    def RsX(val):
        #if w: return val-(1/w)
        #else: return val #1/0 bugfix
        return val
        
    def RsY(val):
        #if h: return val-(1/h)
        #else: return val #1/0 bugfix
        return val
        
    glColor( 0.5 , 0.5 , 0.5 , 0.8 )#post until I make a material
    glBegin(GL_TRIANGLES)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X1--0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glEnd()
    glColor( 0.4 , 0.4 , 0.4 , 0.8 )
    
def display():
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    #draw stuff here:
    HeaderBar(-1,1,1,-1)
    HeaderBar(-1,-0.4,0.92,-1)
    HeaderBar(0.4,1,0.92,-1)
    
    
    glutSwapBuffers()
    
def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGB|GLUT_ALPHA|GLUT_DEPTH|GLUT_DOUBLE)
    glutInitWindowSize(width,height)
    glutCreateWindow("Universal Model Converter v3.0a")

    setup()
    glutDisplayFunc(display)

    glutMainLoop()

main()

I've made another pogram to convert OBJ triangles into gl triangles >_>
so building the GUI parts in blender is easy ^_^

CAN I PLEASE GET SOME HELP WITH THIS D:>

HAN'T ANYONE HERE PROGGED IN OGL IN C++??

IT'S THE EXACT SAME IN PY

whew... I'm done in all caps now...
the blender programmers are a bunch of selfish lamos

if you EVER get a chance to talk to stiv, just ignore his responce...
he'll just lead you in yet another loop that doesn't give you what you're looking for...

I'm in deep water now and I need some help because IDK how to do crap and I'm getting lost in my own GUI...


I've added a resize function that fixes the perspective, but clips the edge of the display...
(so extending the GUI past 1.0 X or Y means nothing)

and then I'm also working on lighting, but can't seem to get it right...
(I'll disable that and work on it later)

here's the code:

import sys
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

global width
global height
width = 640
height = 480

#Light values and coordinates
global ambientLight
global diffuseLight
global specular
global specref
ambientLight = (0.35, 0.35, 0.35, 1.0)
diffuseLight = ( 0.75, 0.75, 0.75, 0.7)
specular = (1.0, 1.0, 1.0, 1.0)
specref = (1.0, 1.0, 1.0, 1.0)

def init():
    glClearColor(0,0,0,1)
    #later
    """
    # Enable depth testing
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_ALPHA_TEST)
    glEnable(GL_LIGHTING)
    glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight)
    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight)
    glLightfv(GL_LIGHT0, GL_SPECULAR, specular)
    glEnable(GL_LIGHT0)
    glEnable(GL_COLOR_MATERIAL)
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE)
    glMaterialfv(GL_FRONT, GL_SPECULAR, specref)
    glMateriali(GL_FRONT, GL_SHININESS, 128)
    glColor3ub(230,100,100)
    """
    

def OptionTriangle(Z):
    w = width-glutGet(GLUT_WINDOW_WIDTH)
    h = height-glutGet(GLUT_WINDOW_HEIGHT)

    #resize functions:
    def RsX(val):
        #if w: return val-(1/w)
        #else: return val #1/0 bugfix
        return val
        
    def RsY(val):
        #if h: return val-(1/h)
        #else: return val #1/0 bugfix
        return val

    glColor( 0.4 , 0.4 , 0.4 , 0.8 )
    glBegin(GL_TRIANGLES)
    glVertex3f(RsX(-0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(-0.0435), RsY(0.9815), Z+0.006081)
    glVertex3f(RsX(-0.04), RsY(0.984), Z+0.006081)
    glVertex3f(RsX(-0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(-0.043), RsY(0.977), Z+0.006081)
    glVertex3f(RsX(-0.0435), RsY(0.9815), Z+0.006081)
    glVertex3f(RsX(-0.043), RsY(0.977), Z+0.006081)
    glVertex3f(RsX(-0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(-0.003), RsY(0.937), Z+0.006081)
    glVertex3f(RsX(-0.043), RsY(0.977), Z+0.006081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.936), Z+0.006081)
    glVertex3f(RsX(-0.003), RsY(0.937), Z+0.006081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(0.003), RsY(0.937), Z+0.006081)
    glVertex3f(RsX(0.0), RsY(0.936), Z+0.006081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.0435), RsY(0.9815), Z+0.006081)
    glVertex3f(RsX(0.043), RsY(0.977), Z+0.006081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.04), RsY(0.984), Z+0.006081)
    glVertex3f(RsX(0.0435), RsY(0.9815), Z+0.006081)
    glVertex3f(RsX(0.0), RsY(0.9645), Z+0.011081)
    glVertex3f(RsX(-0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(-0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.9645), Z+0.011081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(0.0), RsY(0.9645), Z+0.011081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(0.043), RsY(0.977), Z+0.006081)
    glVertex3f(RsX(0.043), RsY(0.977), Z+0.006081)
    glVertex3f(RsX(0.003), RsY(0.937), Z+0.006081)
    glVertex3f(RsX(0.0), RsY(0.94), Z+0.010081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(-0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(-0.04), RsY(0.984), Z+0.006081)
    glVertex3f(RsX(0.04), RsY(0.984), Z+0.006081)
    glVertex3f(RsX(0.04), RsY(0.98), Z+0.010081)
    glVertex3f(RsX(-0.04), RsY(0.984), Z+0.006081)
    glEnd()


def HeaderBar(X1,X2,Y,Z):
    w = width-glutGet(GLUT_WINDOW_WIDTH)
    h = height-glutGet(GLUT_WINDOW_HEIGHT)

    #resize functions:
    def RsX(val):
        #if w<0: return val-(1/w)
        #if w>0: return val+(1/w)
        #else: return val #1/0 bugfix
        return val
        
    def RsY(val):
        #if h<0: return val-(1/h)
        #if h>0: return val+(1/h)
        #else: return val #1/0 bugfix
        return val
        
    glColor( 0.5 , 0.5 , 0.5 , 0.8 )#post until I make a material
    glBegin(GL_TRIANGLES)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X1--0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.05), Z+0.0)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.065), Z+0.0)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.015), RsY(Y-0.075), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.0), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.08), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.0), Z+0.0)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X1--0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.005), RsY(Y-0.05), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.01), RsY(Y-0.063), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.017), RsY(Y-0.07), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.03), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.075), Z+0.005)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.005), Z+0.005)
    glVertex3f(RsX(X1--0.04), RsY(Y-0.04), Z+0.006)
    glVertex3f(RsX(X2-0.04), RsY(Y-0.005), Z+0.005)
    glEnd()
    
def display():
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

    #draw stuff here:
    HeaderBar(-1,1,1,-1);OptionTriangle(-1)
    HeaderBar(-1,-0.4,0.92,-1)
    HeaderBar(0.4,1,0.92,-1)
    
    glutSwapBuffers()

def reshape( w, h):
    lightPos = (-50.0, 50.0, 100.0, 1.0)

    if h==0:
        h = 1
    glViewport(0, 0, w, h)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    
    if w>h:
        glViewport((w-h)/2,0,h,h)
    else:
        glViewport(0,(h-w)/2,w,w)

    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glLightfv(GL_LIGHT0, GL_POSITION, lightPos)

def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGB|GLUT_ALPHA|GLUT_DOUBLE|GLUT_DEPTH)
    glutInitWindowSize(width,height)
    glutCreateWindow("Universal Model Converter v3.0a")

    init()
    
    glutDisplayFunc(display)
    glutReshapeFunc(reshape)
    glutMainLoop()

main()

EDIT:
btw, I plan on getting rid of the RsX and RsY functions...
I'll just calculate the resize values in the main functions.
(I plan on restructuring the code to use a function for each of the main parts of the GUI)
^(there's 9 parts)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.