PDA

View Full Version : OpengGL Vertex Buffer Objects



technomage
19-08-2007, 12:36 PM
Hi

Any ideas on converting this macro to a Delphi function, it's used to specific offsets when using vertex buffer objects which are Interleaved, or serialized under opengl



#define BUFFER_OFFSET(i) ((char*)NULL + (i))



my first attempt is


function BUFFER_OFFSET(i: Integer): Pointer;
begin
Pointer(Longint(Pointer(nil))+i);
end;


comments?

JSoftware
19-08-2007, 02:34 PM
Hi

Any ideas on converting this macro to a Delphi function, it's used to specific offsets when using vertex buffer objects which are Interleaved, or serialized under opengl



#define BUFFER_OFFSET(i) ((char*)NULL + (i))



my first attempt is


function BUFFER_OFFSET(i: Integer): Pointer;
begin
Pointer(Longint(Pointer(nil))+i);
end;


comments?


function BUFFER_OFFSET(i: Integer): Pointer;
begin
result := Pointer(Longint(Pointer(nil))+i);
end;
?

JernejL
19-08-2007, 02:43 PM
function BUFFER_OFFSET(i: longword): Pointer;
var
ptr: pointer absolute i;
begin
result := ptr;
end;

???

technomage
19-08-2007, 06:17 PM
That looks OK, but it's the



(char *)null


bit that gets me.

technomage
19-08-2007, 09:19 PM
Well my version does not work...:(

Delfi - you version appears to do the Job :) nice work , thank you:).