Creating OpenGL windows, requesting libGLESv2.dll after calling gl function.

Hello everyone!

It's been a great 4 years of being without opengl and I guess I've forgotten
things or they've changed.

Here's a simple header what creates a window and should do some openGL stuff.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
#include <vector>
#include <cmath>
#include <windows.h>
#include <thread>
#include <cmath>

#include <gl/gl.h>
#include <gl/glu.h>
using namespace std;

#pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "glu32.lib")

namespace sp {
	class mapWindow {
	public:
		HDC hdc;
		HWND hwnd;
		HINSTANCE hinstance;
		WNDCLASSEX wc;
		wchar_t *wname;
		thread *wloopThread;
		bool EndALL;
		HGLRC hRC;
		float theta;

		static LRESULT CALLBACK messages(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { 
			mapWindow *w = (mapWindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
			if (!w) return DefWindowProc(hwnd, msg, wParam, lParam);

			glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
			glClear(GL_COLOR_BUFFER_BIT);

			glPushMatrix();
			glRotatef(w->theta, 0.0f, 0.0f, 1.0f);
			glBegin(GL_TRIANGLES);
			glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(0.0f, 1.0f);
			glColor3f(0.0f, 1.0f, 0.0f); glVertex2f(0.87f, -0.5f);
			glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(-0.87f, -0.5f);
			glEnd();
			glPopMatrix();

			SwapBuffers(w->hdc);

			w->theta += 1.0f;

			switch (msg)
			{
			case WM_CLOSE:
				DestroyWindow(hwnd);
				// EndALL = true;
				break;
			case WM_DESTROY:
				// PostQuitMessage(0);
				break;
			default:
				return DefWindowProc(hwnd, msg, wParam, lParam);
			}
			return 0;
		}

		static void wloop(mapWindow *w){
			MSG Msg; 
			while (GetMessage(&Msg, NULL, 0, 0) > 0) 
			{ 
				if (w->EndALL) break; 
				TranslateMessage(&Msg); 
				DispatchMessage(&Msg);
			}
		}

		mapWindow(char *Name = "Please map me", int xsize = 890, int ysize = 640, int xpos = 1035, int ypos = 0) {
			wname = new wchar_t[128];
			for (int a = 0; a < 127; a++) {
				if (!Name[a]) { wname[a] = 0; break; }
				wname[a] = Name[a];
			}
			EndALL = false;
			theta = 0.0;
			hinstance = GetModuleHandle(NULL); MSG Msg;
			wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = messages; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
			wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wc.lpszMenuName = NULL; wc.lpszClassName = wname;
			wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
			if (!RegisterClassEx(&wc)) { MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return; }
			hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,wname, wname, WS_OVERLAPPEDWINDOW, xpos, ypos, xsize, ysize, NULL, NULL, hinstance, NULL);
			SetWindowLongPtr(hwnd, GWLP_USERDATA, (long long)this);
			if (hwnd == NULL) { MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK); return; }
			SetWindowText(hwnd, wname);
			ShowWindow(hwnd, SW_SHOWDEFAULT);
			UpdateWindow(hwnd);
			hdc = GetDC(hwnd);

			PIXELFORMATDESCRIPTOR pfd;
			ZeroMemory(&pfd, sizeof(pfd));
			pfd.nSize = sizeof(pfd);
			pfd.nVersion = 1;
			pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
			pfd.iPixelType = PFD_TYPE_RGBA;
			pfd.cColorBits = 24;
			pfd.cDepthBits = 16;
			pfd.iLayerType = PFD_MAIN_PLANE;
			int iFormat = ChoosePixelFormat(hdc, &pfd);
			SetPixelFormat(hdc, iFormat, &pfd);

			hRC = wglCreateContext(hdc);
			wglMakeCurrent(hdc, hRC);
			wglMakeCurrent( NULL, NULL );
			SwapBuffers(hdc); // to render!

			wloopThread = new thread(wloop, this);
		}
		~mapWindow() {
			delete[] wname;
			EndALL = true;
			ReleaseDC(hwnd, hdc);
			// wglMakeCurrent(NULL, NULL);
			wglDeleteContext(hRC);
			Sleep(1000);
			DestroyWindow(hwnd);

			Sleep(1000);
			delete wloopThread;
		}
	};

}


What is going on?
It compiles fine, ofcourse but when I do run it, it requests libGLESv2.dll
it simply should not do that and neither do I have that dll.

I'm compiling the code in visual studio 2015 and its release 64.
What am I missing here or doing wrong?

( I do not wish to use glew or plew, I desire a simple opengl window, nothing fancy pancy )
Thank you!
Try and purge lines 9 and 13. Do not include or link to glu.
Last edited on
I accidentaly included Qt's libraries called libEGL and libGLESv2and didn't even see them
on my input list. I feel very stupid.
Topic archived. No new replies allowed.