Jump to content
  • Advertisement
Sign in to follow this  
PrestoChung

OpenGL Question About Sdl 1.3, Glew & Gl3

This topic is 2891 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was following the tutorial at opengl.org "Creating a Cross Platform OpenGL 3.2 Context in SDL"

Wwhen I got to Tutorial 2 and tried to set up my Shader Program, the related functions all gave error LNK2001: unresolved external symbol (errors from functions like glShaderSource, glCreateProgram, etc.)

A few things here:

1. In the tutorial this is used in SDL initialization:SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
I got my gl3.h file from http://www.opengl.or...istry/api/gl3.h. What version is this file? It has release notes from 2010/03/11 which according to wikipedia should be the release date of version 3.3 and version 4.0. What should I do? I tried changing these functions to 3 and 3 but I still get the same error. I don't think I can do 4.0 because my video card is a GeForce 200 series.

2. I get a glError()1280 invalid enum error when trying to check the SDL_GL_BUFFER_SIZE:int* temp = new int;
SDL_GL_GetAttribute(SDL_GL_BUFFER_SIZE, temp);
cout << "SDL_GL_BUFFER_SIZE: " <<
*temp << endl;
delete temp;
It returns a value of 4976992. It's divisible by 32 but I can't seem to coax my screen resolution out of it so I'm not sure this is a correct value. the SDL spec says that the function returns the framebuffer size in bits and I'm creating the window as 800x600 and SDL_WINDOW_FULLSCREEN

3. I stopped including gl3.h and instead included glew.h and call initGlew(). All shader functions work fine with the context specified as 3 and 3. I also get a glGetError() 1280 invalid enum after calling initGlew(); Dunno what to do about that.

So, should I just eschew the gl3.h file and keep to glew.h for now?

Share this post


Link to post
Share on other sites
Advertisement
The gl3.h header file only works directly like that on linux. On windows you would run a python script that skaslev made that downloads and creates a gl3w.h file for you that you include in your project. This file will only have opengl 3 and 4 functions and is a good way to make sure your only using the new functions.

direct link:
https://github.com/s...ter/gl3w_gen.py

This is a python script that executed on your desktop or whatever you put it will create a folder with the needed files to use opengl3/4 on windows. Your other option would be to use glew which will have both the new and the older functions.

Share this post


Link to post
Share on other sites

The gl3.h header file only works directly like that on linux. On windows you would run a python script that skaslev made that downloads and creates a gl3w.h file for you that you include in your project. This file will only have opengl 3 and 4 functions and is a good way to make sure your only using the new functions.

direct link:
https://github.com/s...ter/gl3w_gen.py

This is a python script that executed on your desktop or whatever you put it will create a folder with the needed files to use opengl3/4 on windows. Your other option would be to use glew which will have both the new and the older functions.


Thanks! I am trying this but getting an access violation on the first gl function that gets called (glGetError, glCreateShader). There's also a lot of warnings generated by gl3w.c, but no errors.

Share this post


Link to post
Share on other sites

Thanks! I am trying this but getting an access violation on the first gl function that gets called (glGetError, glCreateShader). There's also a lot of warnings generated by gl3w.c, but no errors.


call
gl3wInit();

after the context is created. if you have a init function for opengl calls put gl3wInit before init. Everything should work after that.

Share this post


Link to post
Share on other sites
Thanks that is what I needed.

1 last thing:

This gl3w.c file comes up with multiple warnings. Is there a way in Visual Studio to suppress warnings just for 1 source file? I would rather not have any warnings suppressed in the rest of my project.

Share this post


Link to post
Share on other sites

Thanks that is what I needed.

1 last thing:

This gl3w.c file comes up with multiple warnings. Is there a way in Visual Studio to suppress warnings just for 1 source file? I would rather not have any warnings suppressed in the rest of my project.


add this at the beginning of the file:
#pragma warning(disable : "warning number") //disable warning
and
#pragma warning(default: "warning number") //enables warning
at the end of the file

this should do it. the "warning number" should be giving to you ignore the letter before the number.

if you want to know more than look here:

http://msdn.microsoft.com/en-us/library/2c8f766e%28v=vs.80%29.aspx

Share this post


Link to post
Share on other sites
Ah good I knew about the #pragma thing but I didn't know how to disable it.

Is the current method for 2D drawing to render a quad? From what I can tell GL_QUADS is no longer a valid argument for glDrawArrays() I suppose I could use a tri strip.

Share this post


Link to post
Share on other sites

Ah good I knew about the #pragma thing but I didn't know how to disable it.

Is the current method for 2D drawing to render a quad? From what I can tell GL_QUADS is no longer a valid argument for glDrawArrays() I suppose I could use a tri strip.


Yes use triangle strip to make a quad. the quad enum basically converted the data into tri's internally anyway. You can also use point sprites (these have limits).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!