1// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// main.h: Management of thread-local data. 16 17#ifndef LIBGL_MAIN_H_ 18#define LIBGL_MAIN_H_ 19 20#include "Context.h" 21#include "Device.hpp" 22#include "common/debug.h" 23#include "Display.h" 24 25#define _GDI32_ 26#include <windows.h> 27#include <GL/GL.h> 28#include <GL/glext.h> 29 30namespace gl 31{ 32 struct Current 33 { 34 Context *context; 35 Display *display; 36 Surface *drawSurface; 37 Surface *readSurface; 38 }; 39 40 void makeCurrent(Context *context, Display *display, Surface *surface); 41 42 Context *getContext(); 43 Display *getDisplay(); 44 Device *getDevice(); 45 Surface *getCurrentDrawSurface(); 46 Surface *getCurrentReadSurface(); 47 48 void setCurrentDisplay(Display *dpy); 49 void setCurrentContext(gl::Context *ctx); 50 void setCurrentDrawSurface(Surface *surface); 51 void setCurrentReadSurface(Surface *surface); 52} 53 54void error(GLenum errorCode); 55 56template<class T> 57T &error(GLenum errorCode, T &returnValue) 58{ 59 error(errorCode); 60 61 return returnValue; 62} 63 64template<class T> 65const T &error(GLenum errorCode, const T &returnValue) 66{ 67 error(errorCode); 68 69 return returnValue; 70} 71 72extern sw::FrameBuffer *createFrameBuffer(void *display, NativeWindowType window, int width, int height); 73 74#endif // LIBGL_MAIN_H_ 75