SlideShare ist ein Scribd-Unternehmen logo
1 von 32
3D Development with Qt
                
Agenda

    3D Concepts
    OpenGL
    Qt + OpenGL


                   
     
     
We need an API




           
 
    Graphics rendering API
               
Current industry standard for 3D graphics 
             ( Hi DirectX! ) 




                      
MultiPlatform

       MultiLanguage

    Hardware Independent

       Open Standard
               
More than 250 functions to produce 
        three­dimensional scenes


    glColor, glVertex, glTranslate, glRotate ...



                          
Geometric Primitives




              
     
Camera
Physical locations
Projection properties




                            
Lighting

glEnable ( GL_LIGHTING )
Lighting simulates how objects reflect light
Material composition
Light’s color and position
Two sided

GLfloat mred[4]= {1,0,0,1};
glMaterialfv(GL_FRONT, GL_AMBIENT, mred);




                                           
Primitives are specified:
glBegin(primitiveType);
    …
    …
glEnd();
Example:

glBegin(GL_TRIANGLES);    
    glVertex3f( 0.0, 1.0, 0.0 );
    glVertex3f( ­1.0, ­1.0, 0.0 );
    glVertex3f( 1.0, ­1.0, 0.0 );
glEnd();
                               
Color




        
The human eye has 3 types of light receptor 
                  cells 




glColor3f ( GLfloat red, GLfloat green, GLfloat blue );
                           
glBegin(GL_TRIANGLES);
    // red
    glColor3f( 1.0, 0.0, 0.0 );
    glVertex3f( 0.0, 1.0, 0.0 );

    // green
    glColor3f( 0.0, 1.0, 0.0 );
    glVertex3f( ­1.0, ­1.0, 0.0 );

    // blue
    glColor3f( 0.0, 0.0, 1.0 );
    glVertex3f( 1.0, ­1.0, 0.0 );
glEnd();  

                                      
Shading

Smooth:
glShadeModel ( GL_SMOOTH  );    


Flat:
glShadeModel ( GL_FLAT  );  




                         
// Smooth shading
glShadeModel(GL_SMOOTH); 
glBegin(GL_TRIANGLE_STRIP);
        glColor3( 0.0, 0.5, 0.0 );
        glVertex3( ­1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 0.0, 0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.5, 0.0, ­5.0 );

        glColor3( 0.0, 0.0, 1.0 );
        glVertex3( 2.0, ­1.5, ­5.0 );        
    
glEnd();
// Flat shading
glShadeModel(GL_FLAT); 
glBegin(GL_TRIANGLE_STRIP);
        glColor3( 0.0, 0.5, 0.0 );
        glVertex3( ­1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.0, ­0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 0.0, 0.5, ­5.0 );

        glColor3( 1.0, 0.0, 0.0 );
        glVertex3( 1.5, 0.0, ­5.0 );

        glColor3( 0.0, 0.0, 1.0 );
        glVertex3( 2.0, ­1.5, ­5.0 );        
    
glEnd();
 
 
    glTexParameteri( GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR );
                                    
     
+

    Qt OpenGL module
              
#include <QGLWidget>
class GLWidget : public QGLWidget
{
    Q_OBJECT

public:
    GLWidget( QWidget *parent=0 );
    ~GLWidget();
    ...

protected:
    void initializeGL();
    void resizeGL( int width, int height );
    void paintGL();

private:
    ...
                                      

};
    void initializeGL();
    void resizeGL( int width, int height );
    void paintGL();


                        
void GLWidget::initializeGL()
    {

        // Smooth shading
        glShadeModel( GL_SMOOTH ); 

        // Background color
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );  ­>    qglClearColor( Qt::black );

        // Depth buffer setup
        glClearDepth( 1.0f );

        // Enable depth testing
        glEnable( GL_DEPTH_TEST );

        // Set type of depth test
        glDepthFunc( GL_LEQUAL );
                                            
    }
void GLWidget::resizeGL( int width, int height ) 
    {
       
        if ( height == 0 )
            height = 1;

        // Reset current viewport
        GlViewport( 0, 0, width, height ); 

        // Select projection matrix
        GlMatrixMode( GL_PROJECTION ); 
        
        // Reset projection matrix
        glLoadIdentity(); 

        // Select modelview matrix
        GlMatrixMode( GL_MODELVIEW ); 

 
        // Reset modelview matrix          
        glLoadIdentity(); 
void GLWidget::paintGL()
    {
        glClear ( GL_COLOR_BUFFER_BIT );

        // Reset the drawing perspective
        glLoadIdentity(); 

        // triangle
        glBegin (GL_TRIANGLES);
            GlColor3f ( 1.0,  0.0,  0.0 );
            glVertex3f ( 5.0,  5.0, 0.0 );

            glColor3f ( 0.0,  1.0, 0.0 );
            glVertex3f ( 25.0, 5.0, 0.0 );

            glColor3f ( 0.0,  0.0, 1.0 );
            GlVertex3f ( 5.0,  25.0, 0.0 );
        glEnd();                               
    }
void GLWidget::drawtriangle()
{
    glBegin ( GL_TRIANGLES );
        glColor3f ( 1.0,  0.0,  0.0 );
        glVertex3f ( 5.0,  5.0, 0.0 );
   
        glColor3f ( 0.0,  1.0, 0.0 );
        glVertex3f ( 25.0, 5.0, 0.0 );
   
        glColor3f ( 0.0,  0.0, 1.0 );
        glVertex3f ( 5.0,  25.0, 0.0 );
    glEnd();
}
void GLWidget::paintGL()
{
    glClear ( GL_COLOR_BUFFER_BIT );

    // Reset the drawing perspective
    glLoadIdentity(); 
                                           

    drawTriangle();
Demo Animation




           
Demo Rotation




            
Thanks

    Ronny Yabar Aizcorbe

    ronnycontacto@gmail.com
      ronnyml.wordpress.com

                

Weitere ähnliche Inhalte

Ähnlich wie Development with OpenGL and Qt

Ähnlich wie Development with OpenGL and Qt (20)

Programa de objetos 3 d wire
Programa de objetos 3 d wirePrograma de objetos 3 d wire
Programa de objetos 3 d wire
 
Grafika komputer 2
Grafika komputer 2Grafika komputer 2
Grafika komputer 2
 
Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)Ass day2 2_rotating my name (robi)
Ass day2 2_rotating my name (robi)
 
Computer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab reportComputer Graphics and Multimedia lab report
Computer Graphics and Multimedia lab report
 
BYO3D 2011: Rendering
BYO3D 2011: RenderingBYO3D 2011: Rendering
BYO3D 2011: Rendering
 
Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)Tutorial Open GL (Listing Code)
Tutorial Open GL (Listing Code)
 
OpenGL L03-Utilities
OpenGL L03-UtilitiesOpenGL L03-Utilities
OpenGL L03-Utilities
 
Open gl tips
Open gl tipsOpen gl tips
Open gl tips
 
Ujug07presentation
Ujug07presentationUjug07presentation
Ujug07presentation
 
Ass day3 1_bd flag
Ass day3 1_bd flagAss day3 1_bd flag
Ass day3 1_bd flag
 
Robot by gulnaz
Robot by gulnazRobot by gulnaz
Robot by gulnaz
 
Robot by gulnaz
Robot by gulnazRobot by gulnaz
Robot by gulnaz
 
The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185The Ring programming language version 1.5.4 book - Part 54 of 185
The Ring programming language version 1.5.4 book - Part 54 of 185
 
01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt01.Opengl_intro-2.ppt
01.Opengl_intro-2.ppt
 
Bai 1
Bai 1Bai 1
Bai 1
 
Practicing 2d drawing primitives
Practicing 2d drawing primitivesPracticing 2d drawing primitives
Practicing 2d drawing primitives
 
CGLabLec6.pptx
CGLabLec6.pptxCGLabLec6.pptx
CGLabLec6.pptx
 
2D Drawing
2D Drawing2D Drawing
2D Drawing
 
opengl.ppt
opengl.pptopengl.ppt
opengl.ppt
 
Intro to Computer Graphics.ppt
Intro to Computer Graphics.pptIntro to Computer Graphics.ppt
Intro to Computer Graphics.ppt
 

Kürzlich hochgeladen

Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...panagenda
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctBrainSell Technologies
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Hiroshi SHIBATA
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfUK Journal
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxNeo4j
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyUXDXConf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 

Kürzlich hochgeladen (20)

Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptxBT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
BT & Neo4j _ How Knowledge Graphs help BT deliver Digital Transformation.pptx
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 

Development with OpenGL and Qt