Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sb6.h>
- #include <math.h>
- class simplepoint_app : public sb6::application
- {
- void init()
- {
- static const char title[] = "Open GL Point";
- sb6::application::init();
- memcpy(info.title, title, sizeof(title));
- }
- int i = 0;
- int count = 600;
- virtual void render(double currentTime)
- {
- static GLfloat red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
- static GLfloat green[] = { 0.0f, 1.0f, 0.0f, 1.0f };
- static GLfloat blue[] = { 0.0f, 0.0f, 1.0f, 1.0f };
- glUseProgram(program);
- glPointSize(40.0f);
- glDrawArrays(GL_POINTS, 0, 1);
- //glClearBufferfv(GL_COLOR, 0, green);
- }
- virtual void startup()
- {
- //vertex source code
- static const char* vs_source[] = {
- "#version 420 core \n"
- " \n"
- "void main(void) \n"
- "{ \n"
- " \n"
- " gl_Position = vec4(0.0, 0.0, 0.0, 1.0); \n"
- " \n"
- " \n"
- " \n"
- "} \n" };
- static const char* fs_source[] = {
- "#version 420 core \n"
- " \n"
- "out vec4 color; \n"
- "void main (void) \n"
- "{ \n"
- " \n"
- " color = vec4(0.0, 0.8, 1.0, 1.0); \n"
- " \n"
- " \n"
- "} \n" };
- if (program != 0)
- {
- glDeleteProgram(program);
- }
- // Default vs und fs setup
- program = glCreateProgram();
- GLuint vs = glCreateShader(GL_VERTEX_SHADER);
- glShaderSource(vs, 1, vs_source, NULL);
- glCompileShader(vs);
- program = glCreateProgram();
- GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
- glShaderSource(fs, 1, fs_source, NULL);
- glCompileShader(fs);
- glAttachShader(program, vs);
- glAttachShader(program, fs);
- glLinkProgram(program);
- glGenVertexArrays(1, &vao);
- glBindVertexArray(vao);
- }
- virtual void shutdown()
- {
- glDeleteVertexArrays(1, &vao);
- glDeleteProgram(program);
- }
- private:
- GLuint program;
- GLuint vao;
- };
- DECLARE_MAIN(simplepoint_app)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement