Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJevi

Posted 15 December 2012 - 04:47 PM

I have tried looking for the solution but I haven't found anything discussing the whole process.

I'm trying to write my own fractal generator. What I do is I generate coordinates with a color associated with it which is loaded into vector<Point> _points. _points is then used to load the vector<float> _vertexBuffer and vector<float> _colorBuffer which are to be used to draw with the vbo. There might be a problem with the libraries that I'm linking. So suggestions on what opengl extension library I should use for vbos is welcomed. I have a feeling that I'm also not loading data in correctly from the buffers... any help is appreciated.

Here is my code, I'm sure someone could notice the problem pretty easily:


#define NO_SDL_GLEXT
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_opengl.h>

...

unsigned int FractalGenerator::_vertexHandle;
unsigned int FractalGenerator::_colorHandle;
vector<float> FractalGenerator::_vertexBuffer;
vector<float> FractalGenerator::_colorBuffer;

...

struct Color
{
  float r, g, b;
};
struct Point
{
  float x, y;
  Color c;
};

....

for (int i = 0; i < _points.size(); i++)
{
  _vertexBuffer.push_back(_points[i].x);
  _vertexBuffer.push_back(_points[i].y);
  _colorBuffer.push_back(_points[i].c.r);
  _colorBuffer.push_back(_points[i].c.g);
  _colorBuffer.push_back(_points[i].c.b);
}

...

I'm getting a fault here, when I generate the the vbo for _vertexHandle

glGenBuffers(1, &_vertexHandle);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glBufferData(GL_ARRAY_BUFFER, _vertexBuffer.size() * sizeof(float), &_vertexBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &_colorHandle);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glBufferData(GL_ARRAY_BUFFER, _colorBuffer.size() * sizeof(float), &_colorBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

...

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScaled(_zoomFactor, _zoomFactor, 1);
glTranslated(_xOffSet, _yOffSet, 0);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glColorPointer(3, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, _vertexBuffer.size());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
SDL_GL_SwapBuffers();

#6Jevi

Posted 15 December 2012 - 02:22 PM

I have tried looking for the solution but I haven't found anything discussing the whole process.

I'm trying to write my own fractal generator. What I do is I generate coordinates with a color associated with it which is loaded into vector<Point> _points. _points is then used to load the vector<float> _vertexBuffer and vector<float> _colorBuffer which are to be used to draw with the vbo. There might be a problem with the libraries that I'm linking. So suggestions on what opengl extension library I should use for vbos is welcomed. I have a feeling that I'm also not loading data in correctly from the buffers... any help is appreciated.

Here is my code, I'm sure someone could notice the problem pretty easily:


#define NO_SDL_GLEXT
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_opengl.h>

...

unsigned int FractalGenerator::_vertexHandle;
unsigned int FractalGenerator::_colorHandle;
vector<float> FractalGenerator::_vertexBuffer;
vector<float> FractalGenerator::_colorBuffer;

...

struct Color
{
  float r, g, b;
};
struct Point
{
  float x, y;
  Color c;
};

....

for (int i = 0; i < _points.size(); i++)
{
  _vertexBuffer.push_back(_points[i].x);
  _vertexBuffer.push_back(_points[i].y);
  _colorBuffer.push_back(_points[i].c.r);
  _colorBuffer.push_back(_points[i].c.g);
  _colorBuffer.push_back(_points[i].c.b);
}

...

I'm getting a fault here, when I generate the the vbo for _vertexHandle

glGenBuffers(1, &_vertexHandle);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glBufferData(GL_ARRAY_BUFFER, _vertexBuffer.size() * sizeof(float), &_vertexBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &_colorHandle);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glBufferData(GL_ARRAY_BUFFER, _colorBuffer.size() * sizeof(float), &_colorBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

...

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScaled(_zoomFactor, _zoomFactor, 1);
glTranslated(_xOffSet, _yOffSet, 0);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, _vertexBuffer.size());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
SDL_GL_SwapBuffers();

#5Jevi

Posted 15 December 2012 - 02:20 PM

I have tried looking for the solution but I haven't found anything discussing the whole process.

I'm trying to write my own fractal generator. What I do is I generate coordinates with a color associated with it which is loaded into vector<Point> _points. _points is then used to load the vector<float> _vertexBuffer and vector<float> _colorBuffer which are to be used to draw with the vbo. There might be a problem with the libraries that I'm linking. So suggestions on what opengl extension library I should use for vbos is welcomed. I have a feeling that I'm also not loading data in correctly from the buffers... any help is appreciated.

Here is my code, I'm sure someone could notice the problem pretty easily:


#define NO_SDL_GLEXT
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_opengl.h>

...

unsigned int FractalGenerator::_vertexHandle;
unsigned int FractalGenerator::_colorHandle;
vector<float> FractalGenerator::_vertexBuffer;
vector<float> FractalGenerator::_colorBuffer;

...

struct Color
{
  float r, g, b;
};
struct Point
{
  float x, y;
  Color c;
};

....

for (int i = 0; i < _points.size(); i++)
{
  _vertexBuffer.push_back(_points[i].x);
  _vertexBuffer.push_back(_points[i].y);
  _colorBuffer.push_back(_points[i].c.r);
  _colorBuffer.push_back(_points[i].c.g);
  _colorBuffer.push_back(_points[i].c.b);
}

...

I'm getting a fault here, when I generate the the vbo for _vertexHandle

glGenBuffers(1, &_vertexHandle);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glBufferData(GL_ARRAY_BUFFER, _vertexBuffer.size() * sizeof(float), &_vertexBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &;_colorHandle);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glBufferData(GL_ARRAY_BUFFER, _colorBuffer.size() * sizeof(float), &_colorBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

...

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScaled(_zoomFactor, _zoomFactor, 1);
glTranslated(_xOffSet, _yOffSet, 0);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, _vertexBuffer.size());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
SDL_GL_SwapBuffers();

#4Jevi

Posted 15 December 2012 - 02:19 PM

I have tried looking for the solution but I haven't found anything discussing the whole process.

I'm trying to write my own fractal generator. What I do is I generate coordinates with a color associated with it which is loaded into vector<Point> _points. _points is then used to load the vector<float> _vertexBuffer and vector<float> _colorBuffer which are to be used to draw with the vbo. There might be a problem with the libraries that I'm linking. So suggestions on what opengl extension library I should use for vbos is welcomed. I have a feeling that I'm also not loading data in correctly from the buffers... any help is appreciated.

Here is my code, I'm sure someone could notice the problem pretty easily:


#define NO_SDL_GLEXT
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_opengl.h>

...

unsigned int FractalGenerator::_vertexHandle;
unsigned int FractalGenerator::_colorHandle;
vector<float> FractalGenerator::_vertexBuffer;
vector<float> FractalGenerator::_colorBuffer;

...

struct Color
{
  float r, g, b;
};
struct Point
{
  float x, y;
  Color c;
};

....

for (int i = 0; i < _points.size(); i++)
{
  _vertexBuffer.push_back(_points[i].x);
  _vertexBuffer.push_back(_points[i].y);
  _colorBuffer.push_back(_points[i].c.r);
  _colorBuffer.push_back(_points[i].c.g);
  _colorBuffer.push_back(_points[i].c.b);
}

...

I'm getting a fault here, when I generate the the vbo for _vertexHandle

glGenBuffers(1, &amp;_vertexHandle);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glBufferData(GL_ARRAY_BUFFER, _vertexBuffer.size() * sizeof(float), &amp;_vertexBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &amp;_colorHandle);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glBufferData(GL_ARRAY_BUFFER, _colorBuffer.size() * sizeof(float), &amp;_colorBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

...

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScaled(_zoomFactor, _zoomFactor, 1);
glTranslated(_xOffSet, _yOffSet, 0);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, _vertexBuffer.size());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
SDL_GL_SwapBuffers();

#3Jevi

Posted 15 December 2012 - 02:19 PM

I have tried looking for the solution but I haven't found anything discussing the whole process.

I'm trying to write my own fractal generator. What I do is I generate coordinates with a color associated with it which is loaded into vector<Point> _points. _points is then used to load the vector<float> _vertexBuffer and vector<float> _colorBuffer which are to be used to draw with the vbo. There might be a problem with the libraries that I'm linking. So suggestions on what opengl extension library I should use for vbos is welcomed. I have a feeling that I'm also not loading data in correctly from the buffers... any help is appreciated.

Here is my code, I'm sure someone could notice the problem pretty easily:


#define NO_SDL_GLEXT
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_opengl.h>

...

unsigned int FractalGenerator::_vertexHandle;
unsigned int FractalGenerator::_colorHandle;
vector<float> FractalGenerator::_vertexBuffer;
vector<float> FractalGenerator::_colorBuffer;

...

struct Color
{
  float r, g, b;
};
struct Point
{
  float x, y;
  Color c;
};

....

for (int i = 0; i < _points.size(); i++)
{
  _vertexBuffer.push_back(_points[i].x);
  _vertexBuffer.push_back(_points[i].y);
  _colorBuffer.push_back(_points[i].c.r);
  _colorBuffer.push_back(_points[i].c.g);
  _colorBuffer.push_back(_points[i].c.b);
}

...

I'm getting a fault here, when I generate the the vbo for _vertexHandle

glGenBuffers(1, &amp;_vertexHandle);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glBufferData(GL_ARRAY_BUFFER, _vertexBuffer.size() * sizeof(float), &amp;_vertexBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &amp;_colorHandle);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glBufferData(GL_ARRAY_BUFFER, _colorBuffer.size() * sizeof(float), &amp;_colorBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

...

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScaled(_zoomFactor, _zoomFactor, 1);
glTranslated(_xOffSet, _yOffSet, 0);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, _vertexBuffer.size());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
SDL_GL_SwapBuffers();

#2Jevi

Posted 15 December 2012 - 02:19 PM

I have tried looking for the solution but I haven't found anything discussing the whole process.

I'm trying to write my own fractal generator. What I do is I generate coordinates with a color associated with it which is loaded into vector<Point> _points. _points is then used to load the vector<float> _vertexBuffer and vector<float> _colorBuffer which are to be used to draw with the vbo. There might be a problem with the libraries that I'm linking. So suggestions on what opengl extension library I should use for vbos is welcomed. I have a feeling that I'm also not loading data in correctly from the buffers... any help is appreciated.

Here is my code, I'm sure someone could notice the problem pretty easily:


#define NO_SDL_GLEXT
#include <GL/glew.h>
#include <SDL.h>
#include <SDL_opengl.h>

...

unsigned int FractalGenerator::_vertexHandle;
unsigned int FractalGenerator::_colorHandle;
vector<float> FractalGenerator::_vertexBuffer;
vector<float> FractalGenerator::_colorBuffer;

...

struct Color
{
  float r, g, b;
};
struct Point
{
  float x, y;
  Color c;
};

....

for (int i = 0; i < _points.size(); i++)
{
  _vertexBuffer.push_back(_points[i].x);
  _vertexBuffer.push_back(_points[i].y);
  _colorBuffer.push_back(_points[i].c.r);
  _colorBuffer.push_back(_points[i].c.g);
  _colorBuffer.push_back(_points[i].c.b);
}

...

I'm getting a fault here, when I generate the the vbo for _vertexHandle

glGenBuffers(1, &amp;_vertexHandle);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glBufferData(GL_ARRAY_BUFFER, _vertexBuffer.size() * sizeof(float), &amp;_vertexBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &amp;_colorHandle);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glBufferData(GL_ARRAY_BUFFER, _colorBuffer.size() * sizeof(float), &amp;_colorBuffer.front(), GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);

...

glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScaled(_zoomFactor, _zoomFactor, 1);
glTranslated(_xOffSet, _yOffSet, 0);
glBindBuffer(GL_ARRAY_BUFFER, _vertexHandle);
glVertexPointer(2, GL_FLOAT, 0, 0L);
glBindBuffer(GL_ARRAY_BUFFER, _colorHandle);
glVertexPointer(3, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, _vertexBuffer.size());
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glPopMatrix();
SDL_GL_SwapBuffers();

PARTNERS