Chunky by FelipeFS
Chunky by FelipeFS
GPWiki.org
It is currently Mon Jul 28, 2014 10:18 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Apr 18, 2013 6:49 am 
Rookie

Joined: Thu Apr 18, 2013 6:41 am
Posts: 1
Hello.

I have been working on a game engine for a couple of days now and I've had it rendering a colourful cube and playing sounds in OGG format, but, after refractoring my code-base to make life easier it no longer displays the cube! (This happened when I put the shader program and methods into a seperate class)

What could be the problem?

OpenGL/SDL2 context class:
Spoiler: show
Code:
class RenderContext{
   public:
      RenderContext();
      ~RenderContext();

      void draw();

      //void swapbuffers();

      int16_t good;

      ShaderProgram *program;

   private:
      WindowSDL *window;
      FontLoading *fonts;
};


ShaderProgram class:
Spoiler: show
Code:
class ShaderProgram{
   public:   
                ShaderProgram(){
      }

      ShaderProgram(const char *vsPath, const char *fsPath){
         int32_t compileStat, linkStat;
         uint32_t vertexS = glCreateShader(GL_VERTEX_SHADER);
         uint32_t fragS = glCreateShader(GL_FRAGMENT_SHADER);

         string vsSource = LoadFile(vsPath);
         string fsSource = LoadFile(fsPath);
         const char *source = vsSource.c_str();
         glShaderSource(vertexS, 1, &source, NULL);
         source = fsSource.c_str();
         glShaderSource(fragS, 1, &source, NULL);

         glCompileShader(vertexS);
         glGetShaderiv(vertexS, GL_COMPILE_STATUS, &compileStat);
         if(compileStat == 0){
            char BUFFER[256];
            glGetShaderInfoLog(vertexS, sizeof(BUFFER), NULL, BUFFER);
            cerr << "-!- Error compiling vertex shader: " << BUFFER << endl;
            good = false;
            return;
         }

         glCompileShader(fragS);
         glGetShaderiv(fragS, GL_COMPILE_STATUS, &compileStat);
         if(compileStat == 0){
            char BUFFER[256];
            glGetShaderInfoLog(fragS, sizeof(BUFFER), NULL, BUFFER);
            cerr << "-!- Error compiling fragment shader: " << BUFFER << endl;
            good = false;
            return;
         }

         program = glCreateProgram();
         glAttachShader(program, vertexS);
         glAttachShader(program, fragS);

         glLinkProgram(program);
         glGetProgramiv(program, GL_LINK_STATUS, &linkStat);
         if(!linkStat){
            cerr << "-!- Error linking program." << endl;
            good = false;
            return;
         }

         good = true;
      }

      void getUniform(uint32_t &location, const char *uniformName){
         location = glGetUniformLocation(program, uniformName);
         assert(location != 0xFFFFFFFF);
      }

      void bind(){
         glUseProgram(program);
      }

      void unbind(){
         glUseProgram(0);
      }

      ~ShaderProgram(){
         glDeleteProgram(program);
         glUseProgram(0);
      }

      bool good;
      uint32_t program;
};


Included a screenshot of output now and a screenshot of output then.

Thanks.

PICS

BEFORE
Spoiler: show
Image


AFTER
Spoiler: show
Image


Top
 Profile  
 
PostPosted: Fri Apr 19, 2013 9:37 am 
Digerati

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1803
Location: burrowed
First of all:

http://en.wikipedia.org/wiki/Infinity_Engine
Since the internet there is no name that another person hasn't thought of and used it.. it gets kinda annoying after a while :P

for your problem:
Might wanna ged rid of that commented swapbuffers. if you dont swap, you'll only ever update it without sending it to the display.
That's the only think i can make out from your code

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by phpBB® Forum Software © phpBB Group