

Add the following properties to X3Texture:ġ4. Add a new class named "X3Texture" to module X3Core.ġ3. OpenGL.glTexImage2d(OpenGL.GL_TEXTURE_2D, 0, 4, width, height, 0, OpenGL.GL_RGBA, OpenGL.GL_UNSIGNED_BYTE, RGBABitmap)ġ2. OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR)

OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR) OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, OGLName) IMPORTANT: Image dimensions must be in power of 2 (e.g. Add the following method to module X3Core:įunction X3_LoadRGBATexture(RGBABitmap As MemoryBlock, width As Integer, height As Integer) As Integer
#Xojo array code#
Add the following code to the Surface.Resized event handler:ġ1. X3_EnableLight OpenGL.GL_LIGHT0, new X3Core.X3Light(0, 0, 1)ġ0. Add the following code to the Surface.Open event handler: Import the X3Core module, created in the previous tutorial.ĩ. Add the following code to the SurfaceWindow.Paint event handler:Ĩ. Position and size Surface to fill the whole window, and set its locking to left, top, bottom and right.ħ. Enter "Tutorial011" as the Application Name, and click OK.Ħ. Using the above coordinate system as a reference, we can now easily map a texture, or part thereof, to a polygon as shown below.Ģ. The diagram below illustrates the UV-coordinate system, or UV Map, that we use when mapping texture bitmaps to polygons. The image below illustrates how the coordinates of a texture bitmap might be matched with the vertices of polygons. OpenGL will automatically handle the drawing of the texture onto the polygon. We simply need to match the coordinates on a texture bitmap to the vertices of a polygon. The mapping of texture bitmaps onto polygons is a very straightforward process.

Power-of-two dimensions ensure backward compatibility with older hardware and in certain cases improve the rendering speed. It is best practice to ensure that the dimensions of your textures are power-of-two (e.g.
#Xojo array full#
PNG supports loss-less data compression (high quality images) and has full alpha channel support (transparency). The PNG file format is the recommended format for storing texture bitmaps. Consider the following image that could potentially be used as a texture bitmap. Texture mapping is a technique used to "paint" an image, or part thereof, onto a polygon.
