GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 5:13 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Modern OpenGL
PostPosted: Sat Jul 07, 2012 8:54 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
So, I thought I'd get to grips with proper OpenGL, 3.2 and all that.

I'd have been better off spending the day driving rusty nails into my eyes.

GLee seems to be abandoned, so I'll look for something else.
Hmmm, everyone seems to like GLEW, lets try that. Oh Noes! It doesn't do window/context management.
Some tutorials mention GLUT, but that seems to be outdated...
GLFW still seems to be alive and updating... Yay! I have managed to create a window with a 3.3 core profile context!
OK, lets bring in GLEW... Nope everything is crashing. :\
OK, create the GLFW window BEFORE glewInit(), now things are moving in the right direction...
Draw a triangle with new fangled vertex buffers... Nope, nothing on screen.
Turn off core profile and allow legacy API calls... a wild triangle appears. :confused
OK, lets add a shader and see if that helps.
Write a C++ shader loader, GLFW throws a random ASSERT, even when the loader code isn't executed. :doh
Rewrite shader loader using C I/O functions, success! Shader program compiles and links just fine.
Does the shader actually affect the output? No!

RAGEQUIT

Stomps off to see if there's any beer left in the fridge. >:(

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sat Jul 07, 2012 9:48 pm 
Funky Monkey

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1538
Location: burrowed
Haha, yeah it is majorly frustrating until the first things work.
I wouldn't want to start over because i'd basically make a lot of the same mistakes again :P

Here's some awesome stuff you might be interested in though
https://github.com/progschj/OpenGL-Examples

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 1:40 am 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3804
Location: Ferriday, LA, US
Codehead wrote:
Hmmm, everyone seems to like GLEW, lets try that. Oh Noes! It doesn't do window/context management.
Some tutorials mention GLUT, but that seems to be outdated...
GLFW still seems to be alive and updating... Yay! I have managed to create a window with a 3.3 core profile context!
OK, lets bring in GLEW... Nope everything is crashing. :\
OK, create the GLFW window BEFORE glewInit(), now things are moving in the right direction...


I personally just used SDL with GLEW to get things going. GLFW works pretty well, but I prefer SDL for some reason. If you're familiar with SDL, that's a help.

The biggest problem seems to be the shader stuff. You did use both a vertex *and* a fragment shader, right?

EDIT --- You might find http://glm.g-truc.net/ useful, too. :)

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 10:25 am 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
Thanks guys. I was having a grumpy day yesterday. I should have been singing my own version of Gotye - The GL that I used to know...

I'm planning on revisiting the project today, after a good night's sleep.

Weezl, I saw those tuts on my travels, they're pretty good. They put me onto the fact that glewInit() needs pushing down the code until after the context is created.

Clint, I'll take a look at SDL, the random ASSERT is really annoying. I do have a Vert and Frag shader, all compiled and linked with no errors. I was reading some docs somewhere that said that if you don't create one of the shaders in a program, the default functionality is used for that stage, is that not the case?

I've managed to get OpenGL ES 2.0 to play nice on my phone, that's effectively 3.2 core stuff. Plus, I saw some great WebGL stuff while looking for modern GL tuts. I'd like to update the Wiki OpenGL content with Modern GL, ES 2.0 and WebGL versions of the articles. However, I need to get my head around the basics first.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 11:34 am 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Quote:
OpenGL
...
RAGEQUIT

Yeah, sounds like the same process I followed with trying to get the previous OpenGL to render with some shader code. The new version probably has new BS that you must magically know in order to use it.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 12:10 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
OK, Just got my shaders to work.

My shader loader was returning a hard coded zero. :O I missed it because the load and compile worked perfectly within the function (including spotting errors), but nothing ever got returned. :rolleyes

Interestingly, the shader program still compiles with no content. So no matter what code I fed in, I always got a null shader program out with no errors thrown. :doh

I still have the random asset. (I've now built a completely separate class for file I/O and the assert still fires even when the class isn't called.) :confused

Also, I still get no output on screen when I request a 'Forward Compatible 3.3' context. I'm having to use 'Compatibility Profile', which kinda defeats the object seeing as I can still use glBegin/glEnd in that context.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 12:21 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
To answer my own question above:

A shader program built with just a fragment shader seems to work.
However, if there's a vertex shader with no fragment shader, I get no output.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 12:25 pm 
Funky Monkey

Joined: Thu Sep 09, 2004 1:17 pm
Posts: 1538
Location: burrowed
can you paste your code? i'd be curious of whats going on :P

_________________
Long pork is people!

wzl's burrow


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 12:53 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
Which bit?

I'm just building a test project to track down the Assert issue. GLFW and fstream alone don't cause a problem, but as soon as I bring in GLEW, glfwOpenWindow() fails. :confused

Here's a minimal program that generates the assert:

Spoiler: show
Code:
#include <fstream>
#include "GL/glew.h"
#include "GL/glfw.h"


#pragma comment (lib, "opengl32.lib")
#pragma comment (lib, "GL/GLFW.lib")

int main(int argc, char* argv[])
{
 int running = true;

 glfwInit();

 glfwOpenWindow(640, 480, 0,0,0,0,0,0, GLFW_WINDOW);

  // Main loop
 while(running)
  {
   // OpenGL rendering goes here...
   glClear( GL_COLOR_BUFFER_BIT );

   // Swap front and back rendering buffers
   glfwSwapBuffers();

   // Check if ESC key was pressed or window was closed
   running = !glfwGetKey( GLFW_KEY_ESC ) &&
   glfwGetWindowParam( GLFW_OPENED );
  }

 void glfwTerminate(void);

   return 0;
}

void WhySoCrashy()
 {
  std::ifstream testFile("C:\\Test.txt");
 }


glew.c is dumped in the project folder and I've used #define GLEW_STATIC.

Spoiler: show
Code:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: F:\Programming\glfwTest\Debug\glfwTest.exe
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c
Line: 1322

Expression: _CrtIsValidHeapPointer(pUserData)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 1:31 pm 
Harmlessness does no harm
User avatar

Joined: Tue Sep 14, 2004 8:37 pm
Posts: 3804
Location: Ferriday, LA, US
Unless I am mistaken, you need to include the glu32 library when using GLEW (along with opengl32).

_________________
What most people don't understand about "enlightenment" is that it is not an end-goal; but where you find yourself just before taking a new "first step."


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 5:28 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
Mugai wrote:
Unless I am mistaken, you need to include the glu32 library when using GLEW (along with opengl32).


Maybe, I haven't seen any undefined symbol errors yet though.

I did try adding the lib in just in case, but the test code still throws the assert.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
 Post subject: Re: Modern OpenGL
PostPosted: Sun Jul 08, 2012 8:29 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
GLee seems to work just fine. No more asserts. Shame it's a bit out of date.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 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