我画了一个盒子。我添加了处理 vao 和 vbo 的基本类。
class BasicObject_V2
{
public:
BasicObject_V2(GLuint typeOfPrimitives = 0){
this->typeOfPrimitives = typeOfPrimitives;
switch (this->typeOfPrimitives){
case GL_QUADS: numVertsPerPrimitive = 4; break;
}}
void allocateMemory(){
glGenVertexArrays(1, &vaoID);
glBindVertexArray(vaoID);
glGenBuffers(1, &vboID);
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(vertexAttributes), &vertices[0], GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 48, (const void*)0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 48, (const void*)12);
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, 48, (const void*)24);
glVertexAttribPointer(3, 2, GL_FLOAT, GL_FALSE, 48, (const void*)40);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glEnableVertexAttribArray(3);
}
GLuint vboID;
GLuint vaoID;
GLuint typeOfPrimitives;
GLuint …Run Code Online (Sandbox Code Playgroud) 我用C做了一个电话簿程序(带有dinamical结构等).
它在linux下完美运行但是当我尝试在Windows中运行它(在devc ++中编译之后)它启动正常但是在我向列表中添加一些数据之后它就停止并退出.这只是通过向电话簿添加新数据而发生的.当我使用其他功能时,没有中断等等.
在我附加的模块的开头windows.h和conio.hfor getch()和systen("cls").也许我使用了Windows中不允许的某些功能或像这样的smth.
这是我的第一个c项目,通常我在linux上工作,那么我该怎么做呢?
/*SCREEN*/
#ifdef __WIN32__ /*for Windows*/
#include<windows.h>
#define GETCH printf("press ENTER...\n");getch()
#define CLEAR system("cls")
#endif
#ifdef __unix__ /*for unix*/
#include<unistd.h>
#define GETCH printf("\n\npress ENTER...");getchar()
#define CLEAR system("clear")
#endif
Run Code Online (Sandbox Code Playgroud)
我也以同样的方式添加名称和pnonenumber
printf("++ ADD DATA: ++\n");
/*LASTNAME*/
printf(">> add lastname : ");
fgets(buf,128,stdin);
lastname = malloc(strlen(buf)); /*allocate memory for lastdane*/
if( lastname != NULL) /*successful allocation*/
{
strcpy( lastname, buf ); …Run Code Online (Sandbox Code Playgroud)