Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will add to datenwolf's answer. I am assuming that only the shader pipeline is available to you.</p> <p><strong>Requirements</strong></p> <p>In OpenGL 4.0+ Opengl does not do any rendering for you whatsoever as it moves away from the fixed function pipeline. If you are rendering your geometry without a shader right now you are using the deprecated pipeline. Getting up and running without some base framework will be difficult (not impossible, but I would recommend using a base framework). I would recommend, as a start, using <a href="http://freeglut.sourceforge.net/" rel="nofollow">GLUT</a> (this will create a window for you and has basic callbacks for the idle function and input), <a href="http://glew.sourceforge.net/basic.html" rel="nofollow">GLEW</a> (to setup the rendering context) and <a href="http://www.wias-berlin.de/software/gltools/" rel="nofollow">gLTools</a> (matrix stack, generic shaders and shader manager for a quick setup so that you can at least start rendering). </p> <p><strong>Setup</strong></p> <p>I will be giving the important pieces here which you can then piece together. At this point I am assuming you have GLUT set up properly (<a href="http://basic4gl.proboards.com/index.cgi?board=misc&amp;action=display&amp;thread=2415" rel="nofollow">search for how to set it up</a>) and you are able to register the update loop with it and create a window (that is, the loop which calls one of your selected functions [note, this cannot be a method] every frame). Refer to the link above for help on this.</p> <ul> <li>First, <a href="http://glew.sourceforge.net/basic.html" rel="nofollow">initialize glew</a> (by calling <code>glewInit()</code>)</li> <li>Setup your scene. This includes using <strong>GLBatch</strong> class (from glTools) to create a set of vertices to render as triangles and initializing the <strong>GLShaderManager</strong> class (also from GLTools) and its stock shaders by calling its <code>InitializeStockShaders()</code> function.</li> <li>In your idle loop, call <code>UseStockShader()</code> function of the shader manager to start a new batch. Call the <code>draw()</code> function on your vertex batch. For a complete overview of glTools, <a href="http://www.wias-berlin.de/software/gltools/gltools.pdf" rel="nofollow">go here</a>.</li> <li>Don't forget to clear the window before rendering and swapping the buffers after rendering by calling <code>glClear()</code> and <code>glSwapBuffers()</code> respectively.</li> </ul> <p>Note that most of the functions I gave above accept arguments. You should be able to figure those out by looking at the respective library's documentations.</p> <p><strong>MVP Matrix</strong> (EDIT: Forgot to add this section)</p> <p>OpenGL renders everything that is in the -1,1 co-ordinates looking down the z-axis. It has no notion of a camera and does not care for anything that falls outside these co-ordinates. The model-view-projection matrix is what transforms your scene to <em>fit</em> these co-ordinates. </p> <p>As a starting point, don't worry about this until you have something rendered on the screen (make sure all the co-ordinates that you give your vertex batch are less than 1). Once you do, then setup your projection matrix (default projection is orthographic) by using the <code>GLFrustum</code> class in glTools. You will get your projection matrix from this class which you will multiply with your model view matrix. The model-view matrix is a combination of the model's transformation matrix and your <em>camera</em>'s transformation (remember, there is no camera, so essentially, you are moving the scene instead). Once you have multiplied all of them to make one matrix, you pass it on to the shader using the <code>UseStockShader()</code> function.</p> <p>Use a stock shader in GLTools (e.g. <code>GLT_SHADER_FLAT</code>) then start creating your own.</p> <p><strong>Reference</strong></p> <p>Lastly, I would highly recommend getting this book: <a href="http://rads.stackoverflow.com/amzn/click/0321498828" rel="nofollow">OpenGL SuperBible, Comprehensive Tutorial and Reference (Fifth edition - make sure it is this edition)</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload