PDA

View Full Version : glew + sdl problems



spong3bob
06-09-2011, 10:42 AM
Hi!
i got some problems with glew.


#include <Windows.h>
#include <SDL.h>
#include "Settings.h"
#include "Buffer.h"
#include <GL/glew.h>

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
bool running=true;
SDL_Surface *screen;
SDL_Event event;

//Settings::read();
// ----- SDL init ---------------
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Video initialization failed: %s\n", SDL_GetError());
exit(-1);
}

atexit(SDL_Quit);
// ----- OpenGL attribute setting via SDL ---------------
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);

// ----- Setting up the screen surface ---------------
if ((screen = SDL_SetVideoMode(Settings::RESOLUTION_WIDTH, Settings::RESOLUTION_HEIGHT, 0, SDL_OPENGL)) == 0) {
fprintf(stderr, "Video mode set failed: %s\n", SDL_GetError());
exit(-1);
}
GLenum err = glewInit();
if (GLEW_OK != err)
{
MessageBox(0,"error", "err", MB_OK);
return 0;
}
if (GLEW_VERSION_1_3)
{
MessageBox(0,"asdf", "asdf", MB_OK);
}
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
while (running) {

while (SDL_PollEvent(&amp;event)) {
switch (event.type) {
case SDL_QUIT:
running = false;
break;
}
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_GL_SwapBuffers();
}
return 1;
}

compiles fine, also runs, but it says gl version 1.3 is not available (but i even got gl 4.0 running on my pc). things like glClear also work, but when i use glGenFramebuffersEXT(1, &amp;id); e.g. i get a runtime error.

did i miss something? what could be the problem?

_arts_
06-10-2011, 01:05 AM
We can't see pertinent lines in your code about what you're talking about (FBO). So we can't really help you there.

spong3bob
06-10-2011, 04:14 AM
well it's already strange that it doesn't show the message box
if (GLEW_VERSION_1_3)
{
MessageBox(0,"asdf", "asdf", MB_OK);
}

and for the FBO i did it in another file



glGenFramebuffersEXT(1, &amp;id);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, id);
if(flags & BUFFER_DEPTH){
glGenFramebuffersEXT(1, &amp;depth);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, w, h);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth);
}
if(flags & BUFFER_COLOR){
glGenTextures(1, &amp;color0);
glBindTexture(GL_TEXTURE_2D, color0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color0, 0);
}

where w, h are integer and id,depth,color are GLuint.