NO

Author Topic: How to access the proper opengl32  (Read 1602 times)

siwenjo

  • Guest
How to access the proper opengl32
« on: January 10, 2014, 10:40:19 PM »
So far I have the SDL2 side of things working but even though glGetString(GL_VERSION) returns 4.3.12618 Compatibility Profile Context 13.251.0.0 if I call glUseProgram the compilation fails with:

POLINK: error: Unresolved external symbol 'glUseProgram'.
POLINK: fatal error: 1 unresolved external(s).

A verbose compilation shows that the opengl32 lib being linked in is the PellesC provided version and not the 1.1 version that Microsoft provides, so I am at a loss as to why the function is not being found. Actually I am not at a loss, I have just looked through the supplied gl.h and it is the obsolete 1.1 version. So I guess the question is how to get a current opengl32.lib that works in the pellesC environment.

Searching D:\cSDL\PellesC\Lib\SDL2.lib
Searching D:\cSDL\PellesC\Lib\Win64\opengl32.lib
Searching D:\cSDL\PellesC\Lib\crt64.lib
Searching D:\cSDL\PellesC\Lib\Win64\kernel32.lib
Searching D:\cSDL\PellesC\Lib\SDL2.lib
Searching D:\cSDL\PellesC\Lib\Win64\opengl32.lib
Searching D:\cSDL\PellesC\Lib\crt64.lib
Searching D:\cSDL\PellesC\Lib\Win64\kernel32.lib
POLINK: error: Unresolved external symbol 'glUseProgram'.
POLINK: fatal error: 1 unresolved external(s).

How do we tell PellesC to look for the opengl32.dll that the graphics card supplies?

The code I am using is:

Code: [Select]
#define SDL_MAIN_HANDLED


typedef int bool;
#define true 1
#define false 0

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <windows.h>


#include "SDL2/SDL.h"
#include "SDL2/SDL_opengl.h"


#pragma comment(lib, "SDL2.lib")
#pragma comment(lib, "opengl32.lib")

SDL_Window* win;
SDL_GLContext context;
bool running = true;

void setupSDL(void);
void checkError(void);

int main(int argc, char *argv[]){
#ifdef SDL_MAIN_HANDLED
SDL_SetMainReady();
#endif

setupSDL();
checkError();

glUseProgram(0);

while(running){
SDL_Event e;
while(SDL_PollEvent(&e)){
switch(e.type){
case SDL_KEYDOWN:
if(e.key.keysym.sym == SDLK_ESCAPE) running = 0;
break;
default:
break;
}
}

SDL_GL_SwapWindow(win);
}

SDL_GL_DeleteContext(context);
SDL_DestroyWindow(win);
SDL_Quit();

return 0;
}

void setupSDL(void){
SDL_assert(SDL_Init(SDL_INIT_VIDEO) > -1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

int flags = SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN;
win = SDL_CreateWindow("3Doodle", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1024, 768, flags);
SDL_assert(win != NULL);

context = SDL_GL_CreateContext(win);
SDL_assert(context != NULL);
}

void checkError(void){
const char* renderer = (const char*) glGetString(GL_RENDERER);
puts(renderer);
const char* version = (const char*) glGetString(GL_VERSION);
puts(version);
const char* glslVersion = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
puts(glslVersion);

GLenum error = glGetError();
switch(error){
case GL_NO_ERROR: puts("no error"); break;
case GL_INVALID_ENUM: puts("invalid enum"); break;
case GL_INVALID_VALUE: puts("invalid value"); break;
case GL_OUT_OF_MEMORY: puts("out of memory"); break;
case GL_INVALID_FRAMEBUFFER_OPERATION: puts("invalid framebuffer operation"); break;
default: break;
}
}


And the compile bat is:

Code: [Select]
del bin\App.exe
set files=bin\main.o

cc /c -Tamd64-coff -Ze main.c -Fobin\main.o

cc -Wall %files% /OUT:bin\App.exe /VERBOSE

bin\App.exe
« Last Edit: January 10, 2014, 11:42:26 PM by siwenjo »