• Advertisement

Archived

This topic is now archived and is closed to further replies.

OpenGL multi window with opengl

This topic is 5276 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 have created two windows, but my (simple... i hope) problem is to draw into them. Do we have some function to tell OpenGL to render INTO a particular window? (switch between more wnds) possible send HWND or HDC? how? please help, i have no idea...

Share this post


Link to post
Share on other sites
Advertisement
As far as I know OpenGL will always render into the window which is in the same thread. Don''t know of any parameters to pass... Never tried what happens if you have two windows in the same thread, but you could just create two threads, give each it''s own window and gl-commands?

Share this post


Link to post
Share on other sites
no, I think that OpenGL library (=dll) is loaded only once for INSTANCE, threads are only using imported funcs.
idea (maybe helpful) what exactly does wglMakeCurrent() and wglCreateContext() and that third wgl_something_()? I never thought about them.

Share this post


Link to post
Share on other sites
quote:
from MSDN The wglMakeCurrent function makes a specified OpenGL rendering context the calling thread''s current rendering context. All subsequent OpenGL calls made by the thread are drawn on the device identified by hdc. You can also use wglMakeCurrent to change the calling thread''s current rendering context so it''s no longer current.

So, if you have two threads, each OpenGL call inside the thread will be made to the opengl rendering context of that thread. The other stuff is for creating a rendering context and binding it to a window.

Share this post


Link to post
Share on other sites
This should help, it renders 4 opengl screens each in an edit control in a dialogbox. Plus this is in Win32 API
What you can basically do with this is create windows within your window, get their DCs and Wiggles then render.

Main Source File

// windowopengl.cpp : Defines the entry point for the application.

//


#include "stdafx.h"
#include "resource.h"
#include <gl\glut.h>
#include <gl\gl.h>
#include <gl\glaux.h>

#define MAX_LOADSTRING 100

// Global Variables:

HINSTANCE hInst; // current instance

TCHAR szTitle[MAX_LOADSTRING]; // The title bar text

TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text

int TheEnd; // Flag used by thread to end

int xrot; // rotation


// Foward declarations of functions included in this code module:

ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK OpenGL(HWND, UINT, WPARAM, LPARAM);
DWORD WINAPI InitGL(HWND);
int MySetPixelFormat(HDC hdc);
void RenderScene(int);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.

MSG msg;
HACCEL hAccelTable;

// Initialize global strings

LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WINDOWOPENGL, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:

if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_WINDOWOPENGL);

// Main message loop:

while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;
}



//

// FUNCTION: MyRegisterClass()

//

// PURPOSE: Registers the window class.

//

// COMMENTS:

//

// This function and its usage is only necessary if you want this code

// to be compatible with Win32 systems prior to the 'RegisterClassEx'

// function that was added to Windows 95. It is important to call this function

// so that the application will get 'well formed' small icons associated

// with it.

//

ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_WINDOWOPENGL);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_WINDOWOPENGL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}

//

// FUNCTION: InitInstance(HANDLE, int)

//

// PURPOSE: Saves instance handle and creates main window

//

// COMMENTS:

//

// In this function, we save the instance handle in a global variable and

// create and display the main program window.

//

BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable


hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

return TRUE;
}

//

// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)

//

// PURPOSE: Processes messages for the main window.

//

// WM_COMMAND - process the application menu

// WM_PAINT - Paint the main window

// WM_DESTROY - post a quit message and return

//

//

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:

switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
case IDM_OPENGL:
DialogBox(hInst, (LPCTSTR)IDD_OPENGL, hWnd, (DLGPROC)OpenGL);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...

RECT rt;
GetClientRect(hWnd, &rt);
DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Mesage handler for about box.

LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}

// Mesage handler for OpenGL box.

LRESULT CALLBACK OpenGL(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static HANDLE hOpenGL;
static DWORD lpThreadId;

switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
TheEnd=1;
Sleep(500);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
if (LOWORD(wParam) == IDRENDER)
{

EnableWindow(GetDlgItem(hDlg,IDRENDER),FALSE);
hOpenGL=CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)InitGL,hDlg,0,&lpThreadId);

}
break;
}
return FALSE;
}


// Here, we do the regular initialization of OpenGL

DWORD WINAPI InitGL(HWND hDlg)
{
HDC hDC1,hDC2,hDC3,hDC4;
HWND hEdit1,hEdit2,hEdit3,hEdit4;
HGLRC hglrc1,hglrc2,hglrc3,hglrc4;

// First, let's get the handle to all the window we created in the Dialog

// with the resource editor

hEdit1=GetDlgItem(hDlg,IDC_EDIT1);
hEdit2=GetDlgItem(hDlg,IDC_EDIT2);
hEdit3=GetDlgItem(hDlg,IDC_EDIT3);
hEdit4=GetDlgItem(hDlg,IDC_EDIT4);

// For every window, we get the HDC

hDC1=GetDC(hEdit1);
hDC2=GetDC(hEdit2);
hDC3=GetDC(hEdit3);
hDC4=GetDC(hEdit4);

// OpenGL Initialization

glShadeModel(GL_SMOOTH); // Enable Smooth Shading

glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background

glClearDepth(1.0f); // Depth Buffer Setup

glEnable(GL_DEPTH_TEST); // Enables Depth Testing

glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do

glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations


MySetPixelFormat(hDC1);
MySetPixelFormat(hDC2);
MySetPixelFormat(hDC3);
MySetPixelFormat(hDC4);

hglrc1 = wglCreateContext(hDC1);
hglrc2 = wglCreateContext(hDC2);
hglrc3 = wglCreateContext(hDC3);
hglrc4 = wglCreateContext(hDC4);

//render here

while(TheEnd !=1 )
{

// Select first Window as the rendering context and draw to it

wglMakeCurrent(hDC1, hglrc1);
RenderScene(1);
SwapBuffers(hDC1);

// Select second Window as the rendering context and draw to it

wglMakeCurrent(hDC2, hglrc2);
RenderScene(2);
SwapBuffers(hDC2);

// Select third Window as the rendering context and draw to it

wglMakeCurrent(hDC3, hglrc3);
RenderScene(2);
SwapBuffers(hDC3);

// Select fourth Window as the rendering context and draw to it

wglMakeCurrent(hDC4, hglrc4);
RenderScene(1);
SwapBuffers(hDC4);

// Throttle the loop. If we don't put a sleep here, the thread will use 100% cpu

Sleep(1);
}

wglMakeCurrent(NULL, NULL);

// Cleanup

ReleaseDC (hDlg, hDC1) ;
ReleaseDC (hDlg, hDC2) ;
ReleaseDC (hDlg, hDC3) ;
ReleaseDC (hDlg, hDC4) ;

wglDeleteContext(hglrc1);
wglDeleteContext(hglrc2);
wglDeleteContext(hglrc3);
wglDeleteContext(hglrc4);

return TRUE;
}

// Set up the pixel format

int MySetPixelFormat(HDC hdc)
{


PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd

1, // version number

PFD_DRAW_TO_WINDOW | // support window

PFD_SUPPORT_OPENGL | // support OpenGL

PFD_DOUBLEBUFFER, // double buffered

PFD_TYPE_RGBA, // RGBA type

24, // 24-bit color depth

0, 0, 0, 0, 0, 0, // color bits ignored

0, // no alpha buffer

0, // shift bit ignored

0, // no accumulation buffer

0, 0, 0, 0, // accum bits ignored

32, // 32-bit z-buffer

0, // no stencil buffer

0, // no auxiliary buffer

PFD_MAIN_PLANE, // main layer

0, // reserved

0, 0, 0 // layer masks ignored

};

int iPixelFormat;

// get the device context's best, available pixel format match

if((iPixelFormat = ChoosePixelFormat(hdc, &pfd)) == 0)
{
MessageBox(NULL, "ChoosePixelFormat Failed", NULL, MB_OK);
return 0;
}

// make that match the device context's current pixel format

if(SetPixelFormat(hdc, iPixelFormat, &pfd) == FALSE)
{
MessageBox(NULL, "SetPixelFormat Failed", NULL, MB_OK);
return 0;
}

return 1;
}


// This is where we render, in this case, we will draw a simple 3D-Triangle

void RenderScene(int axis)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

if(axis==1) glRotatef(xrot,1.0f,0.0f,0.0f);
if(axis==2) glRotatef(xrot,0.0f,1.0f,0.0f);

glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex3f(0, 0.8f, 0); //top

glColor3f(0, 1, 0);
glVertex3f(-0.5, -0.5, 0.5); //left

glColor3f(0, 0,1);
glVertex3f(0.5, -0.5, 0.5); //right



glColor3f(1.0f,0.0f,0.0f); // Red

glVertex3f( 0.0f, 0.8f, 0.0f); // Top Of Triangle (Right)

glColor3f(0.0f,0.0f,1.0f); // Blue

glVertex3f( .5f,-.5f, .5f); // Left Of Triangle (Right)

glColor3f(0.0f,0.5f,0.0f); // Green

glVertex3f( 0.5f,-0.5f, -0.5f); // Right Of Triangle (Right)


glColor3f(1.0f,0.0f,0.0f); // Red

glVertex3f( 0.0f, 0.8f, 0.0f); // Top Of Triangle (Back)

glColor3f(0.0f,1.0f,0.0f); // Green

glVertex3f( 0.5f,-0.5f, -0.5f); // Left Of Triangle (Back)

glColor3f(0.0f,0.0f,1.0f); // Blue

glVertex3f(-0.5f,-0.5f, -0.5f); // Right Of Triangle (Back)


glColor3f(1.0f,0.0f,0.0f); // Red

glVertex3f( 0.0f, 0.8f, 0.0f); // Top Of Triangle (Left)

glColor3f(0.0f,0.0f,1.0f); // Blue

glVertex3f(-0.5f,-0.5f,-0.5f); // Left Of Triangle (Left)

glColor3f(0.0f,1.0f,0.0f); // Green

glVertex3f(-0.5f,-0.5f, 0.5f); // Right Of Triangle (Left)


glEnd();

xrot+=1.5f;

}


Resource ID file

//{{NO_DEPENDENCIES}}

// Microsoft Developer Studio generated include file.

// Used by windowopengl.rc

//

#define IDC_MYICON 2
#define IDD_WINDOWOPENGL_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDS_HELLO 106
#define IDI_WINDOWOPENGL 107
#define IDI_SMALL 108
#define IDC_WINDOWOPENGL 109
#define IDR_MAINFRAME 128
#define IDD_OPENGL 129
#define IDC_EDIT1 1000
#define IDRENDER 1001
#define IDC_EDIT2 1002
#define IDC_EDIT3 1003
#define IDC_EDIT4 1004
#define IDM_OPENGL 32771
#define IDC_STATIC -1

// Next default values for new objects

//

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif


Resource File

//Microsoft Developer Studio generated resource script.

//

#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 2 resource.

//

#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "resource.h"

/////////////////////////////////////////////////////////////////////////////

#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////

// English (U.S.) resources


#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32


/////////////////////////////////////////////////////////////////////////////

//

// Icon

//


// Icon with lowest ID value placed first to ensure application icon

// remains consistent on all systems.

IDI_WINDOWOPENGL ICON DISCARDABLE "windowopengl.ICO"
IDI_SMALL ICON DISCARDABLE "SMALL.ICO"

/////////////////////////////////////////////////////////////////////////////

//

// Menu

//


IDC_WINDOWOPENGL MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", IDM_EXIT
END
MENUITEM "&OpenGL", IDM_OPENGL
POPUP "&Help"
BEGIN
MENUITEM "&About ...", IDM_ABOUT
END
END


/////////////////////////////////////////////////////////////////////////////

//

// Accelerator

//


IDC_WINDOWOPENGL ACCELERATORS MOVEABLE PURE
BEGIN
"?", IDM_ABOUT, ASCII, ALT
"/", IDM_ABOUT, ASCII, ALT
END


/////////////////////////////////////////////////////////////////////////////

//

// Dialog

//


IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "System"
BEGIN
ICON IDI_WINDOWOPENGL,IDC_MYICON,14,9,16,16
LTEXT "windowopengl Version 1.0",IDC_STATIC,49,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2001",IDC_STATIC,49,20,119,8
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
END

IDD_OPENGL DIALOG DISCARDABLE 0, 0, 304, 170
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Window OpenGL example by Chong Hin Ooi, chongooi@mediaone.net"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "Render",IDRENDER,190,149,50,14
PUSHBUTTON "OK",IDOK,247,149,50,14
EDITTEXT IDC_EDIT1,7,7,138,58,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT2,159,7,138,58,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT3,7,78,138,58,ES_AUTOHSCROLL
EDITTEXT IDC_EDIT4,159,78,138,58,ES_AUTOHSCROLL
END


#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////

//

// TEXTINCLUDE

//


2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""resource.h""\r\n"
"\0"
END

3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END

1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END

#endif // APSTUDIO_INVOKED



/////////////////////////////////////////////////////////////////////////////

//

// DESIGNINFO

//


#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_OPENGL, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 297
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
END
#endif // APSTUDIO_INVOKED



/////////////////////////////////////////////////////////////////////////////

//

// String Table

//


STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "windowopengl"
IDS_HELLO "Window OpenGL example by Chong Hin Ooi"
IDC_WINDOWOPENGL "WINDOWOPENGL"
END

#endif // English (U.S.) resources

/////////////////////////////////////////////////////////////////////////////




#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 3 resource.

//



/////////////////////////////////////////////////////////////////////////////

#endif // not APSTUDIO_INVOKED




Hope that helps.
[edit] Misspelled a tag.

[edited by - Xiachunyi on August 11, 2003 11:59:02 AM]

Share this post


Link to post
Share on other sites
Like the above poster''s example shows... Just create a new OpenGL context for each window and then use wglMakeCurrent and then swap the buffers and then repeat for each window.

Share this post


Link to post
Share on other sites
yeah, now works (it will work in LPS (=limited-planes system) mapeditor, i''ll release it soon). thank you all

(somebody please close this thread...) bye

Share this post


Link to post
Share on other sites
the above two are right. my last renderer used 9 windows (VCL)


OpenGL renders in the selected context in the current thread.

If you have two windows and only need to rendere in one of them at a time, create a context for both and then use wglmakecurrent to select which you wish to render in.

if you want to have both windows being rendered into at the same time, you can either swap the current context between the two (a bit dodgey, but hey, it works) or you can do it the better way and create a two threads. In each thread you have a seperate opengl thread that renders to one of the windows.

Either way, under win32 OpenGL always renders into the THREADS current device context.

I have no idea about macos or os2 or solaris or linux or dos though. I never played with opengl that much under them.

Share this post


Link to post
Share on other sites

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By reenigne
      For those that don't know me. I am the individual who's two videos are listed here under setup for https://wiki.libsdl.org/Tutorials
      I also run grhmedia.com where I host the projects and code for the tutorials I have online.
      Recently, I received a notice from youtube they will be implementing their new policy in protecting video content as of which I won't be monetized till I meat there required number of viewers and views each month.

      Frankly, I'm pretty sick of youtube. I put up a video and someone else learns from it and puts up another video and because of the way youtube does their placement they end up with more views.
      Even guys that clearly post false information such as one individual who said GLEW 2.0 was broken because he didn't know how to compile it. He in short didn't know how to modify the script he used because he didn't understand make files and how the requirements of the compiler and library changes needed some different flags.

      At the end of the month when they implement this I will take down the content and host on my own server purely and it will be a paid system and or patreon. 

      I get my videos may be a bit dry, I generally figure people are there to learn how to do something and I rather not waste their time. 
      I used to also help people for free even those coming from the other videos. That won't be the case any more. I used to just take anyone emails and work with them my email is posted on the site.

      I don't expect to get the required number of subscribers in that time or increased views. Even if I did well it wouldn't take care of each reoccurring month.
      I figure this is simpler and I don't plan on putting some sort of exorbitant fee for a monthly subscription or the like.
      I was thinking on the lines of a few dollars 1,2, and 3 and the larger subscription gets you assistance with the content in the tutorials if needed that month.
      Maybe another fee if it is related but not directly in the content. 
      The fees would serve to cut down on the number of people who ask for help and maybe encourage some of the people to actually pay attention to what is said rather than do their own thing. That actually turns out to be 90% of the issues. I spent 6 hours helping one individual last week I must have asked him 20 times did you do exactly like I said in the video even pointed directly to the section. When he finally sent me a copy of the what he entered I knew then and there he had not. I circled it and I pointed out that wasn't what I said to do in the video. I didn't tell him what was wrong and how I knew that way he would go back and actually follow what it said to do. He then reported it worked. Yea, no kidding following directions works. But hey isn't alone and well its part of the learning process.

      So the point of this isn't to be a gripe session. I'm just looking for a bit of feed back. Do you think the fees are unreasonable?
      Should I keep the youtube channel and do just the fees with patreon or do you think locking the content to my site and require a subscription is an idea.

      I'm just looking at the fact it is unrealistic to think youtube/google will actually get stuff right or that youtube viewers will actually bother to start looking for more accurate videos. 
    • By Balma Alparisi
      i got error 1282 in my code.
      sf::ContextSettings settings; settings.majorVersion = 4; settings.minorVersion = 5; settings.attributeFlags = settings.Core; sf::Window window; window.create(sf::VideoMode(1600, 900), "Texture Unit Rectangle", sf::Style::Close, settings); window.setActive(true); window.setVerticalSyncEnabled(true); glewInit(); GLuint shaderProgram = createShaderProgram("FX/Rectangle.vss", "FX/Rectangle.fss"); float vertex[] = { -0.5f,0.5f,0.0f, 0.0f,0.0f, -0.5f,-0.5f,0.0f, 0.0f,1.0f, 0.5f,0.5f,0.0f, 1.0f,0.0f, 0.5,-0.5f,0.0f, 1.0f,1.0f, }; GLuint indices[] = { 0,1,2, 1,2,3, }; GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertex), vertex, GL_STATIC_DRAW); GLuint ebo; glGenBuffers(1, &ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices,GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(float) * 5, (void*)0); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 2, GL_FLOAT, false, sizeof(float) * 5, (void*)(sizeof(float) * 3)); glEnableVertexAttribArray(1); GLuint texture[2]; glGenTextures(2, texture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); sf::Image* imageOne = new sf::Image; bool isImageOneLoaded = imageOne->loadFromFile("Texture/container.jpg"); if (isImageOneLoaded) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageOne->getSize().x, imageOne->getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageOne->getPixelsPtr()); glGenerateMipmap(GL_TEXTURE_2D); } delete imageOne; glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); sf::Image* imageTwo = new sf::Image; bool isImageTwoLoaded = imageTwo->loadFromFile("Texture/awesomeface.png"); if (isImageTwoLoaded) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageTwo->getSize().x, imageTwo->getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageTwo->getPixelsPtr()); glGenerateMipmap(GL_TEXTURE_2D); } delete imageTwo; glUniform1i(glGetUniformLocation(shaderProgram, "inTextureOne"), 0); glUniform1i(glGetUniformLocation(shaderProgram, "inTextureTwo"), 1); GLenum error = glGetError(); std::cout << error << std::endl; sf::Event event; bool isRunning = true; while (isRunning) { while (window.pollEvent(event)) { if (event.type == event.Closed) { isRunning = false; } } glClear(GL_COLOR_BUFFER_BIT); if (isImageOneLoaded && isImageTwoLoaded) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture[1]); glUseProgram(shaderProgram); } glBindVertexArray(vao); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); glBindVertexArray(0); window.display(); } glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &vbo); glDeleteBuffers(1, &ebo); glDeleteProgram(shaderProgram); glDeleteTextures(2,texture); return 0; } and this is the vertex shader
      #version 450 core layout(location=0) in vec3 inPos; layout(location=1) in vec2 inTexCoord; out vec2 TexCoord; void main() { gl_Position=vec4(inPos,1.0); TexCoord=inTexCoord; } and the fragment shader
      #version 450 core in vec2 TexCoord; uniform sampler2D inTextureOne; uniform sampler2D inTextureTwo; out vec4 FragmentColor; void main() { FragmentColor=mix(texture(inTextureOne,TexCoord),texture(inTextureTwo,TexCoord),0.2); } I was expecting awesomeface.png on top of container.jpg

    • By khawk
      We've just released all of the source code for the NeHe OpenGL lessons on our Github page at https://github.com/gamedev-net/nehe-opengl. code - 43 total platforms, configurations, and languages are included.
      Now operated by GameDev.net, NeHe is located at http://nehe.gamedev.net where it has been a valuable resource for developers wanting to learn OpenGL and graphics programming.

      View full story
    • By TheChubu
      The Khronos™ Group, an open consortium of leading hardware and software companies, announces from the SIGGRAPH 2017 Conference the immediate public availability of the OpenGL® 4.6 specification. OpenGL 4.6 integrates the functionality of numerous ARB and EXT extensions created by Khronos members AMD, Intel, and NVIDIA into core, including the capability to ingest SPIR-V™ shaders.
      SPIR-V is a Khronos-defined standard intermediate language for parallel compute and graphics, which enables content creators to simplify their shader authoring and management pipelines while providing significant source shading language flexibility. OpenGL 4.6 adds support for ingesting SPIR-V shaders to the core specification, guaranteeing that SPIR-V shaders will be widely supported by OpenGL implementations.
      OpenGL 4.6 adds the functionality of these ARB extensions to OpenGL’s core specification:
      GL_ARB_gl_spirv and GL_ARB_spirv_extensions to standardize SPIR-V support for OpenGL GL_ARB_indirect_parameters and GL_ARB_shader_draw_parameters for reducing the CPU overhead associated with rendering batches of geometry GL_ARB_pipeline_statistics_query and GL_ARB_transform_feedback_overflow_querystandardize OpenGL support for features available in Direct3D GL_ARB_texture_filter_anisotropic (based on GL_EXT_texture_filter_anisotropic) brings previously IP encumbered functionality into OpenGL to improve the visual quality of textured scenes GL_ARB_polygon_offset_clamp (based on GL_EXT_polygon_offset_clamp) suppresses a common visual artifact known as a “light leak” associated with rendering shadows GL_ARB_shader_atomic_counter_ops and GL_ARB_shader_group_vote add shader intrinsics supported by all desktop vendors to improve functionality and performance GL_KHR_no_error reduces driver overhead by allowing the application to indicate that it expects error-free operation so errors need not be generated In addition to the above features being added to OpenGL 4.6, the following are being released as extensions:
      GL_KHR_parallel_shader_compile allows applications to launch multiple shader compile threads to improve shader compile throughput WGL_ARB_create_context_no_error and GXL_ARB_create_context_no_error allow no error contexts to be created with WGL or GLX that support the GL_KHR_no_error extension “I’m proud to announce OpenGL 4.6 as the most feature-rich version of OpenGL yet. We've brought together the most popular, widely-supported extensions into a new core specification to give OpenGL developers and end users an improved baseline feature set. This includes resolving previous intellectual property roadblocks to bringing anisotropic texture filtering and polygon offset clamping into the core specification to enable widespread implementation and usage,” said Piers Daniell, chair of the OpenGL Working Group at Khronos. “The OpenGL working group will continue to respond to market needs and work with GPU vendors to ensure OpenGL remains a viable and evolving graphics API for all its customers and users across many vital industries.“
      The OpenGL 4.6 specification can be found at https://khronos.org/registry/OpenGL/index_gl.php. The GLSL to SPIR-V compiler glslang has been updated with GLSL 4.60 support, and can be found at https://github.com/KhronosGroup/glslang.
      Sophisticated graphics applications will also benefit from a set of newly released extensions for both OpenGL and OpenGL ES to enable interoperability with Vulkan and Direct3D. These extensions are named:
      GL_EXT_memory_object GL_EXT_memory_object_fd GL_EXT_memory_object_win32 GL_EXT_semaphore GL_EXT_semaphore_fd GL_EXT_semaphore_win32 GL_EXT_win32_keyed_mutex They can be found at: https://khronos.org/registry/OpenGL/index_gl.php
      Industry Support for OpenGL 4.6
      “With OpenGL 4.6 our customers have an improved set of core features available on our full range of OpenGL 4.x capable GPUs. These features provide improved rendering quality, performance and functionality. As the graphics industry’s most popular API, we fully support OpenGL and will continue to work closely with the Khronos Group on the development of new OpenGL specifications and extensions for our customers. NVIDIA has released beta OpenGL 4.6 drivers today at https://developer.nvidia.com/opengl-driver so developers can use these new features right away,” said Bob Pette, vice president, Professional Graphics at NVIDIA.
      "OpenGL 4.6 will be the first OpenGL release where conformant open source implementations based on the Mesa project will be deliverable in a reasonable timeframe after release. The open sourcing of the OpenGL conformance test suite and ongoing work between Khronos and X.org will also allow for non-vendor led open source implementations to achieve conformance in the near future," said David Airlie, senior principal engineer at Red Hat, and developer on Mesa/X.org projects.

      View full story
    • By _OskaR
      Hi,
      I have an OpenGL application but without possibility to wite own shaders.
      I need to perform small VS modification - is possible to do it in an alternative way? Do we have apps or driver modifictions which will catch the shader sent to GPU and override it?
  • Advertisement