Difference between revisions 1315 and 1316 on hiwikiversity{{कंप्यूटर ग्राफिक्स -- 2013-2014 -- info.uvt.ro/पेज हैडर}} == पूर्ण उदाहरण == दो उदाहरण टेम्पलेट्स यहां दिए गए हैं। एक ऑर्थोग्राफिक प्रोजेक्शन का उपयोग दृश्यों के लिए और एक पर्सपेक्टिव प्रोजेक्शन का उपयोग दृश्यों के लिए। उदाहरणों को भविष्य के जीओजीएल(JOGL) आधारित एप्लीकेशन के लिए टेम्पलेट्स के रूप में इस्तेमाल किया जा सकता हैं। === ऑर्थोग्राफिक प्रोजेक्शन उदाहरण === <source lang="java"> import javax.media.opengl.GL; (contracted; show full) public void display(GLAutoDrawable canvas) { GL2 gl = canvas.getGL().getGL2(); // कैनवास मिटाकर - यह स्पष्ट रंग से भरना gl.glClear(GL.GL_COLOR_BUFFER_BIT); // Add your scene code here // Forcing the scene to be rendered.अपना स्क्रीन कोड यहां जोड़ें // रेन्डरिग करने के लिए स्क्रीन को मजबूर करना gl.glFlush(); } public void reshape(GLAutoDrawable canvas, int left, int top, int width, int height) { GL2 gl = canvas.getGL().getGL2(); // Selecting the viewport -- the display area -- to be the entire widget. gl.glViewport(0, 0, width, height); // Determining the width to height ratio of the widget.व्यूपोर्ट का चयन - डीसप्ल क्षेत्र - पूरे विजेट होने के लिए gl.glViewport(0, 0, width, height); // विजेट का चौड़ाई से ऊँचाई अनुपात निर्धारित करना double ratio = (double) width / (double) height; // Selecting the projection matrix.प्रोजेक्शन मैट्रिक्स का चयन करना gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); // Selecting the view volume to be x from 0 to 1, y from 0 tox 0 से 1, y 0 से 1, z from -1 toसे 1.⏎ // But we are careful to keep the aspect ratio and enlarging the width or the height. वॉल्यूम चुनने, if (ratio < 1) gl.glOrtho(-v_size, v_size, -v_size, v_size / ratio, -1, 1); else gl.glOrtho(-v_size, v_size * ratio, -v_size, v_size, -1, 1); // Selecting the modelview matrix.मॉडलव्यु मैट्रिक्स का चयन करना gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); } public void displayChanged(GLAutoDrawable canvas, boolean modeChanged, boolean deviceChanged) { return; } @Override public void dispose(GLAutoDrawable arg0) { // TODO Auto-generated method stub } } </source> === पर्सपेक्टिव प्रोजेक्शन उदाहरण === <source lang="java"> import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import javax.media.opengl.fixedfunc.GLMatrixFunc; import javax.media.opengl.glu.GLU; import javax.swing.JFrame; import com.jogamp.opengl.util.Animator; public class MainFrame extends JFrame implements GLEventListener { private GLCanvas canvas; private Animator animator; private GLU glu; // Application main entry pointएप्लीकेशन मैन प्रवेश बिंदु public static void main(String args[]) { new MainFrame(); } // Default constructorडिफ़ॉल्ट कन्स्ट्रक्टर; public MainFrame() { super("Java OpenGL"); // Registering a window event listener to handle the closing event.क्लॉजीग एवेन्ट को संभालने के लिए विंडो ईवेंट श्रोता को पंजीकृत करना। this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(800, 600); this.initializeJogl(); this.setVisible(true); } private void initializeJogl() { // Creating a new GL profile.एक नया जीएल प्रोफाइल बनाना GLProfile glprofile = GLProfile.getDefault(); // Creating an object to manipulate OpenGL parametersओपनजीएल पैरामीटर में हेरफेर करने के लिए ऑब्जेक्ट बनाना. GLCapabilities capabilities = new GLCapabilities(glprofile); // Setting some OpenGL parameters.कुछ ओपनजीएल पैरामीटर सेट करना capabilities.setHardwareAccelerated(true); capabilities.setDoubleBuffered(true); // Try to enable 2x anti aliasing. It should be supported on most hardware.2x एन्टी अलियासिंग सक्षम करने का प्रयास करें यह अधिकतर हार्डवेयर पर समर्थित होना चाहिए। capabilities.setNumSamples(2); capabilities.setSampleBuffers(true); // Creating an OpenGL display widget -- canvas.एक ओपन जीएल डिस्प्ले विजेट बनाना - कैनवास this.canvas = new GLCanvas(capabilities); // Adding the canvas in the center of the frame.फ्रेम के केंद्र में कैनवास जोड़ना this.getContentPane().add(this.canvas); // Adding an OpenGL event listener to the canvas.कैनवास के लिए एक ओपन जीएल इवेंट श्रोता को जोड़ना this.canvas.addGLEventListener(this); // Creating an animator that will redraw the scene 40 times per second.एक एनीमेटर बनाना जिससे स्क्रीन प्रति सेकंड 40 बार प्रतिलिपि होगा। this.animator = new Animator(this.canvas); // Registering the canvas to the animator.कैनवास को एनिमेटर में पंजीकृत करना this.animator.add(this.canvas); // Starting the animator.एनीमेटर शुरू करना this.animator.start(); } public void init(GLAutoDrawable canvas) { // Obtaining the GL instance associated with the canvas. कैनवास से संबंधित जीएल उदाहरण प्राप्त करना GL2 gl = canvas.getGL().getGL2(); // Initialize GLU. We'll need it for perspective and camera setup. this.glu = GLU.createGLU(); // Setting the clear color -- the color which will be used to erase the canvas. gl.glClearColor(0, 0, 0, 0); // मॉडलव्यु मैट्रिक्स का चयन करना gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); } public void display(GLAutoDrawable canvas) { GL2 gl = canvas.getGL().getGL2(); //कैनवास मिटाकर - यह स्पष्ट रंग से भरना gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); // अपना स्क्रीन कोड यहां जोड़ें // रेन्डरिग करने के लिए स्क्रीन को मजबूर करना gl.glFlush(); } public void reshape(GLAutoDrawable canvas, int left, int top, int width, int height) { GL2 gl = canvas.getGL().getGL2(); // व्यूपोर्ट का चयन - डीसप्ल क्षेत्र - पूरे विजेट होने के लिए gl.glViewport(0, 0, width, height); // विजेट का चौड़ाई से ऊँचाई अनुपात निर्धारित करना double ratio = (double) width / (double) height; // प्रोजेक्शन मैट्रिक्स का चयन करना gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective (38, ratio, 0.1, 100); // मॉडलव्यु मैट्रिक्स का चयन करना gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); } public void displayChanged(GLAutoDrawable canvas, boolean modeChanged, boolean deviceChanged) { return; } @Override public void dispose(GLAutoDrawable arg0) { } } </source> [[Category:HI]] [[Category:कंप्यूटर ग्राफिक्स]] [[Category:प्रोग्रामिंग उदाहरण]] All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://hi.wikiversity.org/w/index.php?diff=prev&oldid=1316.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|