Testing programming syntax

I’ve struggled when posting programming posts, since WordPress has always improperly formatted them. This is quite unfortunate, since poor formatting can ruin the readability of a post. Luckily, when researching CGI extensions for WordPress (which hopefully allows me to run c++ on WordPress) I stumbled upon a post that claimed I could have proper syntax for programming with just a few lines added into the post. So here goes:


void SetUpSprite(Sprite* sprite, std::string textureName)
{
GLuint VBO;
GLfloat vertices[]={
// Positions // Texture Coords
0.0f, 1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,

0.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 0.0f, 1.0f, 0.0f
};

glGenVertexArrays(1, &sprite->quadVAO);
glGenBuffers(1, &VBO);

glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

glBindVertexArray(sprite->quadVAO);
//send position and Tex as one vec4
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4*sizeof(GLfloat), (GLvoid*)0);

glBindVertexArray(0); //unbind VAO
glBindBuffer(GL_ARRAY_BUFFER, 0); //Unbind VBO

//Load texture and store texture ID.
sprite->texture=LoadTexture("\\"+textureName);
}

The above is some graphics code I had in my game. Seems to look pretty good to me.

Edit: However that last line is a nightmare. It’s supposed to look like this:

sprite->texture=LoadTexture(“\\”+textureName);

Let me try that again


sprite->texture=LoadTexture("\\"+textureName);

Weirdly it now works. This is an odd bug, but I still feel that this is a useful feature.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s