Jump to content
  • Advertisement
Sign in to follow this  
Phil15

OpenGL Opengl ES on Windows 8 using EGL

This topic is 1161 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

Hi,

I am trying to make a cross platform graphics engine where I could write a library test it on my desktop with windows 8 and use the same library with Android/Iphone.(Including OpenGL ES libs ofcourse). As far as I am aware Android uses EGL to render images within a window (Correct me if I am wrong ). A lot of sources keep saying that EGL can be done on windows other say you need WGL, some others say Windows 8 can not support OpenGL ES at all. I also have an Nvidia card and only OpenGL ES libraries that I found are from AMD. Does anyone know what is the best way to get through this problem??

Share this post


Link to post
Share on other sites
Advertisement

well its not that hard as you think. First of all decide which es version you target, then you need to get somekind of wrapper that creates opengl window on every platform you can do that writing different codes for different platforms or use some kind of libs that provide this.

 

Then you just use only OpenGL functions that are avail in your ES version, nothing more nothing less

 

 

OpenGL will work the same way on all platforms if you will be using same functions.

 

 

So for windows you dont link es version you can link normal opengl lib provided with windows...

Edited by WiredCat

Share this post


Link to post
Share on other sites


Then you just use only OpenGL functions that are avail in your ES version, nothing more nothing less
OpenGL will work the same way on all platforms if you will be using same functions.

 

well almost... except for vendor specific bugs and slight differences between versions...

There are not many, but there are a few #ifdefs in our engine if you run it on  "normal" GL instead of GLES. Mostly because of different enum names. Then some function which for some reason has an f for float on the end on GLES but not on GL.

There are also #ifdefs if you run on GLES for android, or GLES for iOS... (again different enum names)

 

Also the shader code had to be slightly modified before the opengl driver liked it.

Share this post


Link to post
Share on other sites

wlll i know that glClearColorf is for es and glClearColor for normal one (not sure if theres glClearColorf for ogl too) but you can typename so it will point onto another,

actually es shader code looks liek be more strict so ogl will eat it.

Share this post


Link to post
Share on other sites

Thank you everyone for your time and replies.
 

Found this link a couple of days ago when a similar question was asked: http://www.g-truc.net/post-0457.html

This very link I also found whilst researching, it said I cannot run EGL or WGL on Windows 8 ....
 

 

well its not that hard as you think. First of all decide which es version you target, then you need to get somekind of wrapper that creates opengl window on every platform you can do that writing different codes for different platforms or use some kind of libs that provide this.

 

Then you just use only OpenGL functions that are avail in your ES version, nothing more nothing less

 

 

OpenGL will work the same way on all platforms if you will be using same functions.

 

 

So for windows you dont link es version you can link normal opengl lib provided with windows...

I am planning on using OpenGL ES 2.0 ...How would I know which functions are supported in ES 2.0 and which are not if I am using openGL ... I mainly used Glut and glew before to run a small graphics engine on a pc but I can no longer use this in Android as android uses EGL, also the plan is making it compatible with ios in future. what is the most efficient approach you can suggest from your experience? What kind of libraries should I use ?

Share this post


Link to post
Share on other sites

list of functions supported by opengl es 2.0

https://www.khronos.org/opengles/sdk/docs/man/

 

 

additionally

 

opengl es 2.0 GL SL shading lang list:

https://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf

 

 

 

please note that even when ES 3.0 device is bacward compatible its not always true, and you will have to rewrite shader s ES 3.0 could read that. (goo way to avoid such thing is not to name variables as "texture" becasue its reserved word for es 3.0 glsl

and actually use mediump highp lowp defines : )

Edited by WiredCat

Share this post


Link to post
Share on other sites


it said I cannot run EGL or WGL on Windows 8 ....

 

Think it says Windows RT, which only goes if you buy one of those Surface tablets with an ARM processor or a Windows Phone. If you have a desktop then it most definitely runs OpenGL as well as anything, a long as you have the Nvidia graphics card driver installed

Share this post


Link to post
Share on other sites

You might want to consider using this: http://community.imgtec.com/developers/powervr/tools/pvrvframe/

 

It's a library from PowerVR, who design the GPUs used by iOS devices and many of those in Android devices. It lets you use GLES on desktop, and apparently interfaces pretty well with some of their performance analysis tools so you can even do some optimisation work on desktop (although you should always measure on a target device).

 

I should say that I haven't used it yet, but I'm planning to try it out. I'm not sure how good of an idea it'd be to use it if you're planning to release on Windows though, at the very least you'd need to carefully read the license agreement, I'm hoping to use it purely to speed up development of mobile-only projects.

Share this post


Link to post
Share on other sites

 


it said I cannot run EGL or WGL on Windows 8 ....

 

Think it says Windows RT, which only goes if you buy one of those Surface tablets with an ARM processor or a Windows Phone. If you have a desktop then it most definitely runs OpenGL as well as anything, a long as you have the Nvidia graphics card driver installed

 


I apologize I did not read that carefully, yes you are correct.


I was trying to go to the basics and at least use opengl in a window (WIN32_API). I managed to create a blank window and supposedly an Opengl context. But I cannot understand how do you use the context, I could not even change the color...
 

#include <Windows.h>
#include <gl\GL.h>
#include <iostream>

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

bool InitMainWindow(HINSTANCE, int);

LRESULT CALLBACK MsgProc(HWND, UINT, WPARAM, LPARAM);

const int WIDTH = 800;
const int HEIGHT= 600;

HWND hwnd = NULL;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	if (!InitMainWindow(hInstance, nCmdShow))
	return 1;

	MSG msg = { 0 };
	HDC hdc = GetDC(hwnd);

	while (WM_QUIT != msg.message)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}
	return 0;

}


bool InitMainWindow(HINSTANCE hInstance, int nCmdShow)
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(wcex);
	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = 0;


	wcex.lpfnWndProc = MsgProc;
	wcex.hInstance = hInstance;
	wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);

	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
	wcex.lpszClassName = "WIndow";
	wcex.lpszMenuName = NULL;
	wcex.hIconSm = LoadIcon(NULL, IDI_WINLOGO);

	if (!RegisterClassEx(&wcex))
	{
		return false;
	}

	hwnd = CreateWindow("WIndow", "Win32", WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_CAPTION
		, GetSystemMetrics(SM_CXSCREEN) / 2 - WIDTH / 2,
		GetSystemMetrics(SM_CYSCREEN) / 2 - HEIGHT / 2,
		WIDTH,
		HEIGHT,
		(HWND)NULL,
		(HMENU)NULL,
		hInstance,
		(LPVOID*)NULL
		);

	if (!hwnd)
		return false;


	ShowWindow(hwnd, nCmdShow);
	return true;

}

LRESULT CALLBACK MsgProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	switch (msg)
	{
	case WM_CREATE:
	{
 		PIXELFORMATDESCRIPTOR pfd =
		{
			sizeof(PIXELFORMATDESCRIPTOR),
			1,
			PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,    //Flags
			PFD_TYPE_RGBA,            //The kind of framebuffer. RGBA or palette.
			32,                        //Colordepth of the framebuffer.
			0, 0, 0, 0, 0, 0,
			0,
			0,
			0,
			0, 0, 0, 0,
			24,                        //Number of bits for the depthbuffer
			8,                        //Number of bits for the stencilbuffer
			0,                        //Number of Aux buffers in the framebuffer.
			PFD_MAIN_PLANE,
			0,
			0, 0, 0
		};

		HDC ourWindowHandleToDeviceContext = GetDC(hwnd);

		int  letWindowsChooseThisPixelFormat;
		letWindowsChooseThisPixelFormat = ChoosePixelFormat(ourWindowHandleToDeviceContext, &pfd);
		SetPixelFormat(ourWindowHandleToDeviceContext, letWindowsChooseThisPixelFormat, &pfd);

		HGLRC ourOpenGLRenderingContext = wglCreateContext(ourWindowHandleToDeviceContext);
		bool value = wglMakeCurrent(ourWindowHandleToDeviceContext, ourOpenGLRenderingContext);

		
		while (1)
		{
			glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
		}
		//MessageBoxA(0, (char*)glGetString(GL_VERSION), "OPENGL VERSION", 0);

		wglDeleteContext(ourOpenGLRenderingContext);
		PostQuitMessage(0);
	}
	break;

	case WM_DESTROY: //recieved destroy msg
		PostQuitMessage(0);
		return 0;
	}

	return DefWindowProc(hwnd, msg, wparam, lparam);


}




 

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!