' loop through all the vertexes of the polygon OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, ) ' bind to the polygon's texture OpenGL.glColor4d(1, 1, 1, 1) ' reset color to pure white ' is this polygon mapped with a texture, and if so, is the UV coordinates configured? Poly = model.Polygon(i) ' get the next polygon ![]() OpenGL.glPolygonMode openGL.GL_FRONT, openGL.GL_FILLįor i = 0 to ' loop through all the polygons OpenGL.glBegin OpenGL.GL_TRIANGLES ' start drawing triangle polygons Public Sub X3_RenderModel(model As X3Core.X3Model) OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT + OpenGL.GL_DEPTH_BUFFER_BIT) OpenGL.glTexImage2d(OpenGL.GL_TEXTURE_2D, 0, 4, width, height, 0, OpenGL.GL_RGBA, OpenGL.GL_UNSIGNED_BYTE, RGBABitmap)įinally the Render method and RenderModel that is called from it.įunction Render() Handles Render as Boolean OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR) // set up some more settings OpenGL.glTexParameteri(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR) // set up settings OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, OGLName) ' select the texture id that OpenGL allocated for our texture ' specify to OpenGL how this texture should be rendered OglName = idMB.Long(0) ' store the value returned by OpenGL in an integer OpenGL.glGenTextures(1, idMB) ' get the ID from OpenGL IdMB = new MemoryBlock(4) ' create a memory block into which OpenGL will store the ID value ' ask OpenGL for an ID that we can use for our texture ' // IMPORTANT: Image dimensions must be in power of 2 (e.g. Public Function X3_LoadRGBATexture(RGBABitmap As MemoryBlock, width As Integer, height As Integer) as Integer I did have some issues with masks due to the old way vs new way Xojo implements, but the sample I have doesn’t use any masks. This is how the OGLName is created (many asked if this was the source of the problem) OGLName = X3_LoadRGBATexture(RGBABitmap, Width, Height) Offset = offset + 4 ' move to the next pixel in our OpenGL texture bitmap RGBABitmap.Byte(offset + 2) = textCol.Blue RGBABitmap.Byte(offset + 1) = textCol.Green ' store the color and alpha values into our OpenGL texture bitmap ' calculate the OpenGL alpha values, using the mask values of the pixelĪlpha = 255 - (textMaskCol.Red + textMaskCol.Green + textMaskCol.Blue) / 3 TextMaskCol = m.RGBSurface.Pixel(x, y) ' get the mask (alpha) color of the current pixel TextCol = (x,y) ' get the color of the current pixel ’ loop through all the pixels of the pictureįor x = 0 to Width - 1 ' read the values of the current pixel RGBABitmap = new MemoryBlock(Height * Width * 4) ’ create a MemoryBlock for the OpenGL RGBA format Using the X thoughtful examples from the constructor of the texture wrapper is as follows. P2.UVMap.Append new X3Core.X3UVCoordinate(1,0) P2.UVMap.Append new X3Core.X3UVCoordinate(1,1) P2.UVMap.Append new X3Core.X3UVCoordinate(0,1) ![]() P.UVMap.Append new X3Core.X3UVCoordinate(0,0)ĭim t as new X3Core.X3Texture( imageb ) // this is the only texture that will show regardless of what texture is loaded after. P.UVMap.Append new X3Core.X3UVCoordinate(1,0) P.UVMap.Append new X3Core.X3UVCoordinate(0,1) M.Vertex.Append new X3Core.X3Vector( 1, -1, 0 ) // 3 M.Vertex.Append new X3Core.X3Vector( 1, 1, 0) // 2 I have this in the open event of my OpenG3Surface It won’t show at all… If I comment out the textured polygons the non-textured will appear again.The first loaded texture shows on both polygons.set them to the same texture (and only load one texture).** If anyone helps me solve this and is going to XDC there will surely be consumable rewards for the help!!! (?) I’m positive this will be a one line fix when it’s done… Sigh.Īgain here’s the scenario spelled out a little more clear (maybe it will jog something…) Is it possible to add a project or zip to the thread? Seems that would be easier than trying to copy the relevant bits here.
0 Comments
Leave a Reply. |