Restablished core context creation, removed debug messages
This commit is contained in:
parent
5d816122c8
commit
a4cbe46e15
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_OCCLUSIONQUERY_HPP
|
||||
#define NAZARA_OCCLUSIONQUERY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Utility/NonCopyable.hpp>
|
||||
|
||||
class NAZARA_API NzOcclusionQuery : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzOcclusionQuery();
|
||||
~NzOcclusionQuery();
|
||||
|
||||
void Begin();
|
||||
void End();
|
||||
|
||||
unsigned int GetResult() const;
|
||||
|
||||
bool IsResultAvailable() const;
|
||||
|
||||
static bool IsSupported();
|
||||
|
||||
private:
|
||||
unsigned int m_id;
|
||||
};
|
||||
|
||||
#endif // NAZARA_OCCLUSIONQUERY_HPP
|
||||
|
|
@ -83,6 +83,13 @@ bool NzBuffer::Create(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage
|
|||
|
||||
if (!m_impl)
|
||||
{
|
||||
if (!NazaraRenderer->HasCapability(nzRendererCap_SoftwareBuffer))
|
||||
{
|
||||
// Ne devrait jamais arriver
|
||||
NazaraError("Software buffer not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_impl = new NzSoftwareBuffer(this, m_type);
|
||||
if (!m_impl->Create(length*typeSize, usage))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/OcclusionQuery.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
NzOcclusionQuery::NzOcclusionQuery() :
|
||||
m_id(0)
|
||||
{
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
if (IsSupported())
|
||||
#endif
|
||||
glGenQueries(1, reinterpret_cast<GLuint*>(&m_id));
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
else
|
||||
{
|
||||
NazaraError("Occlusion queries not supported");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (!m_id)
|
||||
{
|
||||
NazaraError("Failed to create occlusion query");
|
||||
throw std::runtime_error("Constructor failed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
NzOcclusionQuery::~NzOcclusionQuery()
|
||||
{
|
||||
if (m_id)
|
||||
glDeleteQueries(1, reinterpret_cast<GLuint*>(&m_id));
|
||||
}
|
||||
|
||||
void NzOcclusionQuery::Begin()
|
||||
{
|
||||
glBeginQuery(GL_SAMPLES_PASSED, m_id);
|
||||
}
|
||||
|
||||
void NzOcclusionQuery::End()
|
||||
{
|
||||
glEndQuery(GL_SAMPLES_PASSED);
|
||||
}
|
||||
|
||||
unsigned int NzOcclusionQuery::GetResult() const
|
||||
{
|
||||
GLuint result;
|
||||
glGetQueryObjectuiv(m_id, GL_QUERY_RESULT, &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool NzOcclusionQuery::IsResultAvailable() const
|
||||
{
|
||||
GLint available;
|
||||
glGetQueryObjectiv(m_id, GL_QUERY_RESULT_AVAILABLE, &available);
|
||||
|
||||
return available == GL_TRUE;
|
||||
}
|
||||
|
||||
bool NzOcclusionQuery::IsSupported()
|
||||
{
|
||||
return NazaraRenderer->HasCapability(nzRendererCap_OcclusionQuery);
|
||||
}
|
||||
|
|
@ -379,14 +379,14 @@ bool NzOpenGL::Initialize()
|
|||
|
||||
/****************************************Contextes****************************************/
|
||||
|
||||
/*
|
||||
|
||||
NzContextParameters::defaultMajorVersion = openGLversion/100;
|
||||
NzContextParameters::defaultMinorVersion = (openGLversion%100)/10;
|
||||
*/
|
||||
|
||||
/*
|
||||
NzContextParameters::defaultMajorVersion = std::min(openGLversion/100, 2U);
|
||||
NzContextParameters::defaultMinorVersion = std::min((openGLversion%100)/10, 1U);
|
||||
|
||||
*/
|
||||
if (!NzContext::InitializeReference())
|
||||
{
|
||||
NazaraError("Failed to initialize reference context");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Renderer/Context.hpp>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
NzContextImpl::NzContextImpl()
|
||||
|
|
@ -33,14 +32,14 @@ bool NzContextImpl::Create(NzContextParameters& parameters)
|
|||
else
|
||||
{
|
||||
m_window = CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr);
|
||||
ShowWindow(m_window, SW_HIDE);
|
||||
m_ownsWindow = true;
|
||||
|
||||
if (!m_window)
|
||||
{
|
||||
NazaraError("Failed to create window");
|
||||
return false;
|
||||
}
|
||||
|
||||
ShowWindow(m_window, SW_HIDE);
|
||||
m_ownsWindow = true;
|
||||
}
|
||||
|
||||
m_deviceContext = GetDC(m_window);
|
||||
|
|
@ -130,7 +129,7 @@ bool NzContextImpl::Create(NzContextParameters& parameters)
|
|||
return false;
|
||||
}
|
||||
|
||||
// Arrivé ici, tout est créé, nous récupérons donc les paramètres actuels du contexte
|
||||
// Arrivé ici, le format de pixel est choisi, nous récupérons donc les paramètres réels du futur contexte
|
||||
if (DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0)
|
||||
{
|
||||
parameters.bitsPerPixel = descriptor.cColorBits + descriptor.cAlphaBits;
|
||||
|
|
@ -142,21 +141,9 @@ bool NzContextImpl::Create(NzContextParameters& parameters)
|
|||
|
||||
HGLRC shareContext = (parameters.shared) ? static_cast<NzContextImpl*>(parameters.shareContext->m_impl)->m_context : nullptr;
|
||||
|
||||
std::cout << "Context version: " << (int) parameters.majorVersion << '.' << (int) parameters.minorVersion << std::endl;
|
||||
std::cout << "Active context: " << wglGetCurrentContext() << std::endl;
|
||||
|
||||
m_context = nullptr;
|
||||
if (wglCreateContextAttribs)
|
||||
{
|
||||
std::cout << "wglCreateContextAttribs" << std::endl;
|
||||
|
||||
/*int attributes[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, parameters.majorVersion,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, parameters.minorVersion,
|
||||
WGL_CONTEXT_FLAGS_ARB, (parameters.compatibilityProfile) ? 0 : WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
WGL_CONTEXT_PROFILE_MASK_ARB, (parameters.compatibilityProfile) ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||
0
|
||||
};*/
|
||||
int attributes[4*2+1];
|
||||
int* attrib = attributes;
|
||||
|
||||
|
|
@ -183,37 +170,20 @@ bool NzContextImpl::Create(NzContextParameters& parameters)
|
|||
*attrib++ = 0;
|
||||
|
||||
m_context = wglCreateContextAttribs(m_deviceContext, shareContext, attributes);
|
||||
|
||||
if (m_context)
|
||||
std::cout << "Context created with success ! Pointer: " << m_context << std::endl;
|
||||
else
|
||||
std::cout << "wglCreateContextAttribs failed ! (glGetError(): " << glGetError() << ") " << std::endl;
|
||||
}
|
||||
|
||||
if (!m_context)
|
||||
{
|
||||
std::cout << "wglCreateContext" << std::endl;
|
||||
|
||||
m_context = wglCreateContext(m_deviceContext);
|
||||
if (m_context)
|
||||
std::cout << "Context created with success ! Pointer: " << m_context << std::endl;
|
||||
else
|
||||
std::cout << "wglCreateContext failed ! (glGetError(): " << glGetError() << ") " << std::endl;
|
||||
|
||||
if (shareContext)
|
||||
{
|
||||
std::cout << "Sharing context with context " << shareContext << std::endl;
|
||||
// wglShareLists n'est pas thread-safe (source: SFML)
|
||||
static NzMutex mutex;
|
||||
NzLock lock(mutex);
|
||||
|
||||
if (wglShareLists(shareContext, m_context))
|
||||
std::cout << "Success !" << std::endl;
|
||||
else
|
||||
{
|
||||
std::cout << "Failed !" << std::endl;
|
||||
if (!wglShareLists(shareContext, m_context))
|
||||
NazaraWarning("Failed to share the context: " + NzGetLastSystemError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -224,8 +194,6 @@ bool NzContextImpl::Create(NzContextParameters& parameters)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue