Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create the 3D object in question, without displaying it.<br> <br> You can get the bounds of the object as pixel locations by using gluProject (to get the pixels that represent the object's edges. You can then use gluUnProject to map the intervening pixels to the object's coordinates.<br> <br> Then, you start your draw over, and map a custom (on-the-fly) texture over the same object and display it.<br> <br> Not sure why you'd want to do this, but that should be a good starting point.<br> <br> Edit:<br> <br> What I mean by custom, is if the bounds of your object (in one dimension,) are -3.0 to 1.0, and the first pixel row is from -3.0 to -2.0, your texture map is going to indicate that 25% of your custom texture maps over that spot, and you create it all with the color of the pixel you want to show there.<br> <br> After thinking that through, I realized you could just draw a texture over the top of the projected screen coordinates (using the 2D drawing facilities.)<br> <br> I think that gets the gist of your idea across. I don't think it would work well in an interactive 3D demo, if the 'object' comes closer and moves away, if the texture doesn't seem to scale up and down. But you didn't say what you were actually doing.<br> <br> Edit 2:<br> <br> OpenGL 2D Projection:<br> <br> <br> CAUTION<br> Careful with the function names, e.g., opengles 1.1 has glOrthox and glOrthof. Make sure you check what is available in your gl.h header file.<br></p> <pre><code>const XSize = 640, YSize = 480 glMatrixMode (GL_PROJECTION) glLoadIdentity () glOrtho (0, XSize, YSize, 0, 0, 1) glMatrixMode (GL_MODELVIEW) glDisable(GL_DEPTH_TEST) glClear(GL_COLOR_BUFFER_BIT) // Now draw with 2i or 2f vertices instead of the normal vertex3f functions. // And for ES, of course set up your data structures and call drawarrays ofr drawelements. SwapBuffers() </code></pre> <p>This will allow you to draw 2D shapes in OpenGL (much more simply than using 3D projections.) To mix the two, e.g., draw in 3D then in 2D, follow the second link.<br> <br> Here's an excellent tutorial on 2D drawing:<br> <a href="http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL" rel="nofollow noreferrer">http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL</a><br> <br> Here's the basics on mixing the two:<br> <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=96440" rel="nofollow noreferrer">http://www.gamedev.net/community/forums/topic.asp?topic_id=96440</a><br> <br> I hope that is what you want. I get a sneaking suspicion from your post that you're having trouble mapping your texture across triangle points to make it show up 'straight'. You might want to review basic texture mapping on NeHe:<br> <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=96440" rel="nofollow noreferrer">http://www.gamedev.net/community/forums/topic.asp?topic_id=96440</a><br> E.g., gltexcoord2f specifies the point (0.0-1.0) within the texture in terms of the percentage of width and height of the texture that maps to the next drawn vertex. With triangle fans, you can have some mathematical conniptions to figure out what % of width and height of the overall object you are specifying with the vertex.<br> <br> Take, for example, a sphere with a texture map (a mercator projection of the earth,) is best mapped by calculating the lines of latitude as a basis for your underlying triangle fan vertex values, as it eases calculation of the texture coordinates. Making your polygons approximate simple geometric shapes allows you to use trigonometry to more easily calculate texture coordinates.<br> <br> I hope this is helpful.<br> <br> Hehere, I'll quit going on with desktop examples you have to modifiy. Here's an OpenGLES example that does proper 3D texture mapping. You can use what I said above, and this example, to do 2D texture mapping.<br> <a href="http://www.zeuscmd.com/tutorials/opengles/17-TextureMapping.php" rel="nofollow noreferrer">http://www.zeuscmd.com/tutorials/opengles/17-TextureMapping.php</a><br></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