Registriert: Fr Feb 22, 2013 13:43 Beiträge: 9
Programmiersprache: Lazarus FPC Linux
Fixed.. It was not my original question in as much as I was hoping to use something like glGenBuffers but in the case of glVertexArrays for a 'sanity' check I tried glBegin(GL_LINES)|glEnd just to see that my data was constructed correctly. Then I wondered if my 'pointer' was pointing to anything meaningful, it might as well have been the printer port for all I knew..
DaMadMax is right about the 'pointer indexing'...
Code:
glVertexPointer(2, GL_INT, 0, @GridBufferX);
2 for X|Y coordinates. I assume GL_LINES tells the graphics card to step through these in pairs.. As it turns out it was down to the way I referenced the array using @GridBufferX as the pointer,
to reference the first element of the array and doing that gives,
I see the point from StucUK about 2D versus 3D but I think the initialisation tells the card that it is working on 2D data and it adjusts accordingly. Textures... I'll probably have to use them sometime although I feel they may turn out to be overly complex for this particular requirement. To hard for me to get my head around.
Having said that it would be nice to draw the Grid once and then store it as a texture and load that back in rather than repeatedly draw the Grid and overlay the Cursor on top, if that makes sense.
I'll code this back into the original and see what, if any, improvement it gives.
Yeh i wasn't thinking. The glVertexPointer's have a parameter to specify how many "elements" there are. A texture for the grid isn't all that hard to implement. You just draw a Square(Quad) and take your standard texture coordinates for rendering the texture so its fits completely over the surface and modify them to : TextureCoord * (Size/TextureSize) + Offset/TextureSize .
BTW, when you draw whatever your drawing(Not talking about the grid but whats drawn on top of it), you should render it using Polygons/Triangles rather than lines as they are faster. You can use glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); to switch to wireframe and glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); to switch back.
The following code has not been tested. Note that you shouldn't use glBegin/glEnd but its easier to make example code with them .
Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.