Fix OpenGL 2.0 declarations so code builds on Windows & Android
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1225 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
40c07d20e5
commit
6b02c619e7
@ -28,6 +28,7 @@
|
|||||||
#include <GL/freeglut.h>
|
#include <GL/freeglut.h>
|
||||||
#include "fg_internal.h"
|
#include "fg_internal.h"
|
||||||
#include "fg_gl2.h"
|
#include "fg_gl2.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need more types of polyhedra? See CPolyhedron in MRPT
|
* Need more types of polyhedra? See CPolyhedron in MRPT
|
||||||
@ -74,21 +75,21 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n
|
|||||||
|
|
||||||
if (numVertices > 0 && attribute_v_coord != -1) {
|
if (numVertices > 0 && attribute_v_coord != -1) {
|
||||||
fghGenBuffers(1, &vbo_coords);
|
fghGenBuffers(1, &vbo_coords);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords);
|
||||||
fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]),
|
fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]),
|
||||||
vertices, GL_STATIC_DRAW);
|
vertices, FGH_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numVertices > 0 && attribute_v_normal != -1) {
|
if (numVertices > 0 && attribute_v_normal != -1) {
|
||||||
fghGenBuffers(1, &vbo_normals);
|
fghGenBuffers(1, &vbo_normals);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals);
|
||||||
fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]),
|
fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]),
|
||||||
normals, GL_STATIC_DRAW);
|
normals, FGH_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vbo_coords) {
|
if (vbo_coords) {
|
||||||
fghEnableVertexAttribArray(attribute_v_coord);
|
fghEnableVertexAttribArray(attribute_v_coord);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords);
|
||||||
fghVertexAttribPointer(
|
fghVertexAttribPointer(
|
||||||
attribute_v_coord, // attribute
|
attribute_v_coord, // attribute
|
||||||
3, // number of elements per vertex, here (x,y,z)
|
3, // number of elements per vertex, here (x,y,z)
|
||||||
@ -101,7 +102,7 @@ static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei n
|
|||||||
|
|
||||||
if (vbo_normals) {
|
if (vbo_normals) {
|
||||||
fghEnableVertexAttribArray(attribute_v_normal);
|
fghEnableVertexAttribArray(attribute_v_normal);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals);
|
||||||
fghVertexAttribPointer(
|
fghVertexAttribPointer(
|
||||||
attribute_v_normal, // attribute
|
attribute_v_normal, // attribute
|
||||||
3, // number of elements per vertex, here (x,y,z)
|
3, // number of elements per vertex, here (x,y,z)
|
||||||
@ -185,28 +186,28 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte
|
|||||||
|
|
||||||
if (numVertices > 0 && attribute_v_coord != -1) {
|
if (numVertices > 0 && attribute_v_coord != -1) {
|
||||||
fghGenBuffers(1, &vbo_coords);
|
fghGenBuffers(1, &vbo_coords);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords);
|
||||||
fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]),
|
fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(vertices[0]),
|
||||||
vertices, GL_STATIC_DRAW);
|
vertices, FGH_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numVertices > 0 && attribute_v_normal != -1) {
|
if (numVertices > 0 && attribute_v_normal != -1) {
|
||||||
fghGenBuffers(1, &vbo_normals);
|
fghGenBuffers(1, &vbo_normals);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals);
|
||||||
fghBufferData(GL_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]),
|
fghBufferData(FGH_ARRAY_BUFFER, numVertices * 3 * sizeof(normals[0]),
|
||||||
normals, GL_STATIC_DRAW);
|
normals, FGH_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertIdxs != NULL) {
|
if (vertIdxs != NULL) {
|
||||||
fghGenBuffers(1, &ibo_elements);
|
fghGenBuffers(1, &ibo_elements);
|
||||||
fghBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_elements);
|
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements);
|
||||||
fghBufferData(GL_ELEMENT_ARRAY_BUFFER, numVertIdxs * sizeof(vertIdxs[0]),
|
fghBufferData(FGH_ELEMENT_ARRAY_BUFFER, numVertIdxs * sizeof(vertIdxs[0]),
|
||||||
vertIdxs, GL_STATIC_DRAW);
|
vertIdxs, FGH_STATIC_DRAW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vbo_coords) {
|
if (vbo_coords) {
|
||||||
fghEnableVertexAttribArray(attribute_v_coord);
|
fghEnableVertexAttribArray(attribute_v_coord);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_coords);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_coords);
|
||||||
fghVertexAttribPointer(
|
fghVertexAttribPointer(
|
||||||
attribute_v_coord, // attribute
|
attribute_v_coord, // attribute
|
||||||
3, // number of elements per vertex, here (x,y,z)
|
3, // number of elements per vertex, here (x,y,z)
|
||||||
@ -219,7 +220,7 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte
|
|||||||
|
|
||||||
if (vbo_normals) {
|
if (vbo_normals) {
|
||||||
fghEnableVertexAttribArray(attribute_v_normal);
|
fghEnableVertexAttribArray(attribute_v_normal);
|
||||||
fghBindBuffer(GL_ARRAY_BUFFER, vbo_normals);
|
fghBindBuffer(FGH_ARRAY_BUFFER, vbo_normals);
|
||||||
fghVertexAttribPointer(
|
fghVertexAttribPointer(
|
||||||
attribute_v_normal, // attribute
|
attribute_v_normal, // attribute
|
||||||
3, // number of elements per vertex, here (x,y,z)
|
3, // number of elements per vertex, here (x,y,z)
|
||||||
@ -233,7 +234,7 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLubyte
|
|||||||
if (vertIdxs == NULL) {
|
if (vertIdxs == NULL) {
|
||||||
glDrawArrays(GL_TRIANGLES, 0, numVertices);
|
glDrawArrays(GL_TRIANGLES, 0, numVertices);
|
||||||
} else {
|
} else {
|
||||||
fghBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_elements);
|
fghBindBuffer(FGH_ELEMENT_ARRAY_BUFFER, ibo_elements);
|
||||||
glDrawElements(GL_TRIANGLES, numVertIdxs, GL_UNSIGNED_BYTE, 0);
|
glDrawElements(GL_TRIANGLES, numVertIdxs, GL_UNSIGNED_BYTE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,32 +27,16 @@
|
|||||||
#include "fg_internal.h"
|
#include "fg_internal.h"
|
||||||
#include "fg_gl2.h"
|
#include "fg_gl2.h"
|
||||||
|
|
||||||
void glutSetVertexAttribCoord3(GLint attrib) {
|
void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib) {
|
||||||
if (fgStructure.CurrentWindow != NULL)
|
if (fgStructure.CurrentWindow != NULL)
|
||||||
fgStructure.CurrentWindow->Window.attribute_v_coord = attrib;
|
fgStructure.CurrentWindow->Window.attribute_v_coord = attrib;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glutSetVertexAttribNormal(GLint attrib) {
|
void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib) {
|
||||||
if (fgStructure.CurrentWindow != NULL)
|
if (fgStructure.CurrentWindow != NULL)
|
||||||
fgStructure.CurrentWindow->Window.attribute_v_normal = attrib;
|
fgStructure.CurrentWindow->Window.attribute_v_normal = attrib;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
|
||||||
typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
|
||||||
typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, fghGLsizeiptr size, const GLvoid *data, GLenum usage);
|
|
||||||
typedef void (APIENTRY *PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers);
|
|
||||||
typedef void (APIENTRY *PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
|
|
||||||
typedef void (APIENTRY *PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint);
|
|
||||||
typedef void (APIENTRY *PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
|
|
||||||
|
|
||||||
PFNGLGENBUFFERSPROC fghGenBuffers = NULL;
|
|
||||||
PFNGLDELETEBUFFERSPROC fghDeleteBuffers = NULL;
|
|
||||||
PFNGLBINDBUFFERPROC fghBindBuffer = NULL;
|
|
||||||
PFNGLBUFFERDATAPROC fghBufferData = NULL;
|
|
||||||
PFNGLENABLEVERTEXATTRIBARRAYPROC fghEnableVertexAttribArray = NULL;
|
|
||||||
PFNGLDISABLEVERTEXATTRIBARRAYPROC fghDisableVertexAttribArray = NULL;
|
|
||||||
PFNGLVERTEXATTRIBPOINTERPROC fghVertexAttribPointer = NULL;
|
|
||||||
|
|
||||||
void fgInitGL2() {
|
void fgInitGL2() {
|
||||||
fgState.HasOpenGL20 = 0;
|
fgState.HasOpenGL20 = 0;
|
||||||
#define CHECK(func, a) if ((a) == NULL) { fgWarning("fgInitGL2: " func " is NULL"); return; }
|
#define CHECK(func, a) if ((a) == NULL) { fgWarning("fgInitGL2: " func " is NULL"); return; }
|
||||||
|
@ -30,6 +30,12 @@
|
|||||||
# define APIENTRY
|
# define APIENTRY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* extension #defines, types and entries, avoiding a dependency on additional
|
||||||
|
libraries like GLEW or the GL/glext.h header */
|
||||||
|
#define FGH_ARRAY_BUFFER 0x8892
|
||||||
|
#define FGH_STATIC_DRAW 0x88E4
|
||||||
|
#define FGH_ELEMENT_ARRAY_BUFFER 0x8893
|
||||||
|
|
||||||
typedef ptrdiff_t fghGLsizeiptr;
|
typedef ptrdiff_t fghGLsizeiptr;
|
||||||
typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
|
||||||
typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
|
||||||
|
Reference in New Issue
Block a user